我的代码看起来像这样:
OAConsumer *consumer = [[OAConsumer alloc] initWithKey:@"my_ClientID"
secret:@"my_Secret"];
NSURL *url = [NSURL URLWithString:@"https://launchpad.37signals.com/authorization/token"];
OAMutableURLRequest *request = [[OAMutableURLRequest alloc] initWithURL:url
consumer:consumer
token:nil // we don't have a Token yet
realm:nil // our service provider doesn't specify a realm
signatureProvider:nil]; // use the default method, HMAC-SHA1
[request setHTTPMethod:@"POST"];
NSLog(@"USER URL : %@",[request URL]);
OADataFetcher *fetcher = [[OADataFetcher alloc] init];
[fetcher fetchDataWithRequest:request
delegate:self
didFinishSelector:@selector(requestTokenTicket:didFinishWithData:)
didFailSelector:@selector(requestTokenTicket:didFailWithError:)];
- (void)requestTokenTicket:(OAServiceTicket *)ticket didFinishWithData:(NSData *)data {
if (ticket.didSucceed) {
NSString *responseBody = [[NSString alloc] initWithData:data
encoding:NSUTF8StringEncoding];
OAToken *requestToken = [[OAToken alloc] initWithHTTPResponseBody:responseBody];
NSLog(@"%@",requestToken);
}
}
我的委托方法永远不会获得(ticket.didSucceed)成功。
有人可以告诉我这里缺少什么吗?
由于
答案 0 :(得分:0)
看起来您正试图让用户授权您的应用并首次生成令牌。为此,您使用的是错误的网址。来自37Signals API:
- 您的应用通过将用户重定向到Launchpad来请求授权: https://launchpad.37signals.com/authorization/new?type=web_server&client_id=your-client-id&redirect_uri=your-redirect-uri
醇>
您使用的网址是从验证码中获取访问令牌。