【问题标题】:Issue with OAuth authentication for the new Basecamp Api using OAConsumer使用 OAConsumer 的新 Basecamp Api 的 OAuth 身份验证问题
【发布时间】:2016-09-21 01:23:50
【问题描述】:

我的代码看起来像这样:

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);
    }
}

我的 Delegate 方法永远不会获得 (ticket.didSucceed) 成功。

谁能告诉我这里缺少什么?

谢谢

【问题讨论】:

    标签: ios api oauth basecamp


    【解决方案1】:

    您似乎正试图让用户首次授权您的应用并生成令牌。为此,您使用了错误的 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 用于从验证码中获取访问令牌。

    【讨论】:

    • @Mark S. 和 shyambhat 你能给我一些时间吗,我需要你关于 Basecamp Next Api 的帮助。电子邮件是:khalid0491@gmail.com 谢谢
    猜你喜欢
    • 2023-03-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-08
    • 2011-06-12
    • 1970-01-01
    • 2014-05-02
    • 1970-01-01
    相关资源
    最近更新 更多