使用 OAConsumer 的新 Basecamp Api 的 OAuth 身份验证问题

问题描述 投票:0回答:1

我的代码看起来像这样:

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) 成功。

有人可以告诉我我在这里缺少什么吗?

ios oauth basecamp
1个回答
0
投票

看起来您正在尝试让用户首次授权您的应用程序并生成令牌。为此,您使用了错误的 URL。来自37Signals API

  1. 您的应用程序通过将用户重定向到 Launchpad 来请求授权: https://launchpad.37signals.com/authorization/new?type=web_server&client_id=your-client-id&redirect_uri=your-redirect-uri

您使用的URL用于从验证码中获取访问令牌。

© www.soinside.com 2019 - 2024. All rights reserved.