我在OAuth流程中完成了以下步骤:
1)请求令牌
2)授权令牌
3)接收PIN号码
我无法工作的是使用我收到的PIN获取访问令牌。它始终会点击我的accessTokenTicket:didFailWithError
选择器。
以下是传递给它的网址:
http://www.formspring.me/oauth/access_token?oauth_token=TOKEN_KEY_HERE&oauth_verifier=PIN_HERE
这是被调用的代码:
- (void)successfulAuthorizationWithPin:(NSString *)pin {
NSLog(@"successfulAuthorizationWithPin:%@", pin);<br>
OAMutableURLRequest *request;<br>
OADataFetcher *fetcher;
NSURL *url = [NSURL URLWithString:kOAuthAccessTokenURL];
request = [[[OAMutableURLRequest alloc] initWithURL:url
consumer:self.consumer
token:self.accessToken
realm:nil
signatureProvider:nil] autorelease];
OARequestParameter *p0 = [[OARequestParameter alloc] initWithName:@"oauth_token" value:self.accessToken.key];
OARequestParameter *p1 = [[OARequestParameter alloc] initWithName:@"oauth_verifier"
value:pin];
NSArray *params = [NSArray arrayWithObjects:p0, p1, nil];
[request setParameters:params];
[request prepare];
NSLog(@"%@", request.URL);
fetcher = [[[OADataFetcher alloc] init] autorelease];
[fetcher fetchDataWithRequest:request
delegate:self
didFinishSelector:@selector(accessTokenTicket:didFinishWithData:)
didFailSelector:@selector(accessTokenTicket:didFailWithError:)];
[p0 release];
[p1 release];
}
didFail
方法(只是错误的NSLog
)会产生此错误:
Error Domain=NSURLErrorDomain Code=-1012 "The operation couldn’t be completed. (NSURLErrorDomain error -1012.)" UserInfo=0x6160c20 {NSErrorFailingURLKey=http://www.formspring.me/oauth/access_token?oauth_token=TOKEN_KEY_HERE&oauth_verifier=PIN_HERE, NSErrorFailingURLStringKey=http://www.formspring.me/oauth/access_token?oauth_token=TOKEN_KEY_HERE&oauth_verifier=PIN_HERE, NSUnderlyingError=0x61321f0 "The operation couldn’t be completed. (kCFErrorDomainCFNetwork error -1012.)"}
我是否将网址格式错误或提供错误或不足的参数?
谢谢!
约翰
答案 0 :(得分:3)
您是否检查生成的oauth令牌是否正确?我建议从那里开始。 Here's是检查OAuth令牌的好资源。
如果出现身份验证错误,则会显示该消息。通过Netflix Oauth验证生成URL并在浏览器上运行。看看它是否加载。