【发布时间】:2011-06-22 08:51:53
【问题描述】:
我在 OAuth 过程中完成了以下步骤:
1) 请求令牌
2) 授权令牌
3) 接收 PIN 码
我无法使用收到的 PIN 获取访问令牌。它总是点击我的accessTokenTicket:didFailWithError 选择器。
这是传递给它的 URL:
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.)"}
我的 URL 格式是否错误或提供的参数错误或不足?
谢谢!
约翰
【问题讨论】:
标签: iphone oauth oauth-2.0 access-token nsurlerrordomain