簡體   English   中英

Vimeo身份驗證OAuth2

[英]Vimeo authentication OAuth2

我正在嘗試通過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身份驗證和上傳的示例嗎?

當我將回調URL更改為自己的回調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字符串;)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM