【问题标题】:Vimeo authentication OAuth2Vimeo 认证 OAuth2
【发布时间】:2015-05-22 17:03:09
【问题描述】:

我正在尝试通过 iOS 应用向 Vimeo 进行身份验证。我正在使用GTMOAuth2Authentication Oauth2 库。我的代码如下:

- (void)signInToVimeo
{
    GTMOAuth2Authentication * auth = [self authForVimeo];

    GTMOAuth2ViewControllerTouch * viewController = 
    [[GTMOAuth2ViewControllerTouch alloc] initWithAuthentication:auth

    authorizationURL:[NSURL URLWithString:@""]

    keychainItemName:@"VimeoKeychainItem"
                                                                                 delegate:self

    finishedSelector:@selector(viewController:

    finishedWithAuth:error:)];

    [self.navigationController pushViewController:viewController animated:YES];
}

- (GTMOAuth2Authentication * )authForVimeo
{
    NSURL * tokenURL = [NSURL URLWithString:VIMEO_REQUEST_TOKEN_URL];

    NSString * redirectURI = @"vimeoTest://";

    GTMOAuth2Authentication * auth;

    auth = [GTMOAuth2Authentication   

    authenticationWithServiceProvider:@"Vimeo"

    tokenURL:tokenURL

    redirectURI:redirectURI

    clientID:CLIENT_ID                                   

    clientSecret:SECRET_KEY];
    auth.scope = @"edit";
    return auth;
}

- (void)viewController:(GTMOAuth2ViewControllerTouch * )viewController
      finishedWithAuth:(GTMOAuth2Authentication * )auth
                 error:(NSError * )error
{
    NSLog(@"auth access token: %@", auth.accessToken);
    NSLog(@"%@", [error localizedDescription]);
}

我在应用程序和 Vimeo 开发者网站的 URL 方案中设置了相同的回调 URL vimeoTest://。 Vimeo 登录屏幕显示良好,输入登录凭据后要求“允许”或“取消”;没关系,但是当我点击“允许”时,我没有获得带有错误消息“com.google.HTTPStatus 错误 404”的设备令牌。有没有 Vimeo 认证和上传的例子?

【问题讨论】:

    标签: ios objective-c authentication oauth vimeo


    【解决方案1】:

    当我将回调 URL 更改为我自己的时,我遇到了同样的错误。这是因为如果您使用 VIMNetworking,回调 URL 必须采用 vimeoCLIENT_ID 形式。为什么?如果你检查 VIMNetworking 来源你会注意到

    - (id<VIMRequestToken>)authenticateWithCodeGrantResponseURL:(NSURL *)responseURL completionBlock:(VIMAccountCompletionBlock)completionBlock
    

    使用

    - (NSString *)codeGrantRedirectURI
    {
       NSString *authRedirectScheme = [NSString stringWithFormat:@"vimeo%@", self.clientKey];
       NSString *authRedirectPath = @"auth";
       return [NSString stringWithFormat:@"%@://%@", authRedirectScheme, authRedirectPath];
    } 
    

    查看 authRedirectScheme 字符串 ;)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-05-28
      • 2018-09-04
      • 2022-08-24
      • 1970-01-01
      • 2016-05-10
      • 2014-12-17
      • 2021-06-22
      相关资源
      最近更新 更多