通过iPhone应用程序进行vimeo oth身份验证

问题描述 投票:2回答:2

我有一个iPad应用程序,需要将vimeo集成到其中。我正处于将其集成到我的应用程序的初期。我首先需要通过vimeo对我的应用进行身份验证。

我已经完成了文档中的身份验证步骤,并且能够通过前两个步骤:

请求令牌:http://vimeo.com/oauth/request_token

用户授权:http://vimeo.com/oauth/authorize

但是无法通过上一步获得oauth_tokenoauth_token_secret

访问令牌:http://vimeo.com/oauth/access_token

Vimeo重定向到回调URL,而不是返回到应用程序,这直到我得到验证者和授权令牌后才可以。但是一旦我使用它们获取oauth_tokenoauth_token_secret,控制台就会显示以下错误消息:

Error Domain=NSURLErrorDomain Code=-1012 "The operation couldn’t be completed. 
(NSURLErrorDomain error -1012.)" UserInfo=0x18146180 {
    NSErrorFailingURLKey=http://vimeo.com/oauth/access_token?oauth_token=141b4ff56c48dc5d03501297bde85ebc&oauth_verifier=land-1886924229, 
    NSErrorFailingURLStringKey=http://vimeo.com/oauth/access_token?oauth_token=141b4ff56c48dc5d03501297bde85ebc&oauth_verifier=land-1886924229, 
    NSUnderlyingError=0x181483d0 "The operation couldn’t be completed. (kCFErrorDomainCFNetwork error -1012.)"
}

任何人都可以提供帮助或至少提供一些指示吗?

为了进一步说明问题,我正在使用OAuthConsumer框架。下面是我们放置请求以获取访问令牌的代码行:

- (void)successfulAuthorizationWithToken:(NSString *)token verifier:(NSString *)verifier  {
    NSLog(@"successfulAuthorizationWithToken");
    OAMutableURLRequest *request;
    OADataFetcher *fetcher;

    //NSURL *url = [NSURL URLWithString:@"https://api.twitter.com/oauth/access_token"];
    NSURL *url = [NSURL URLWithString:@"http://vimeo.com/oauth/access_token"];
    request = [[[OAMutableURLRequest alloc] initWithURL:url
                                               consumer:self.consumer
                                                  token:self.accessToken
                                                  realm:nil
                                      signatureProvider:nil autorelease];


    OARequestParameter *p0 = [[OARequestParameter alloc] initWithName:@"oauth_token"
                                                                value:token];
    OARequestParameter *p1 = [[OARequestParameter alloc] initWithName:@"oauth_verifier"
                                                                value:verifier];
    NSArray *params = [NSArray arrayWithObjects:p0, p1, nil];
    [request setParameters:params];

    fetcher = [[[OADataFetcher alloc] init] autorelease];

    [fetcher fetchDataWithRequest:request
                         delegate:self
                didFinishSelector:@selector(accessTokenTicket:didFinishWithData:)
                  didFailSelector:@selector(accessTokenTicket:didFailWithError:)];

    [p0 release];
    [p1 release];

}

我还尝试了以下链接中指定的解决方案:Twitter API + OAuthConsumer.framework

[将[[[OAHMAC_SHA1SignatureProvider alloc] init] autorelease]用作signatureProvider。但是结果是相同的。

使用访问令牌步骤获取验证者和授权令牌后,我需要获取以下值:oauth_token=YourAuthorizedOauthToken&oauth_token_secret=YourAuthorizedTokenSecret

ipad authentication vimeo
2个回答
0
投票

您需要在请求中提供您自己的回调,该回调看起来像myapp://...,并在iOS中注册myapp处理程序,以便重定向浏览器时,iOS会将控制权交还给您的应用。我假设您正确使用了OAuth,并从您的应用启动浏览器进行用户交互。或者,您可以使用WebView(不是OAuth推荐的),然后在WebView委托中可以捕获重定向并解析access toke


0
投票

最后终于成功了。基本字符串和oAuth标头字符串格式存在问题。

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.