【问题标题】:Is there a 23andMe oauth2 example for iPhone?是否有适用于 iPhone 的 23andMe oauth2 示例?
【发布时间】:2014-02-21 09:51:36
【问题描述】:

我正在尝试使用 oauth2 从 23 和我那里获取数据,但不断收到“错误请求”代码。这是我第一次使用 OAuth2,我不确定我做错了什么。

当我使用 AFOAuth2Client 时,我得到错误代码 400:

AFOAuth2Client* oauthClient = [AFOAuth2Client clientWithBaseURL:[NSURL URLWithString:@"https://api.23andme.com/"] clientID:clientIDString secret:secretString];



    [oauthClient authenticateUsingOAuthWithPath:@"/token/"
                                           code:@"zzz"
                                    redirectURI:@"myapp://callback/oauth"
                                          scope:@"analyses"
                                        success:^(AFOAuthCredential *credential)
     {
         NSLog(@"I have a token! %@", credential.accessToken);
         [AFOAuthCredential storeCredential:credential withIdentifier:oauthClient.serviceProviderIdentifier];
     }
                                        failure:^(NSError *error) {
                                            NSLog(@"Error: %@", error);
                                        }];

此消息命中错误块:

Error: Error Domain=com.alamofire.networking.error Code=-1011 "Expected status code in (200-299), got 400" UserInfo=0x1fda4f80 {NSErrorFailingURLKey=https://api.23andme.com/token/, NSLocalizedDescription=Expected status code in (200-299), got 400}

当我尝试 GTMOauth2Sample 时,授权屏幕消失后出现 invalid_client 错误。

我做错了什么?

【问题讨论】:

    标签: iphone objective-c oauth-2.0 23andme-api


    【解决方案1】:

    您可以尝试从 23andme https://github.com/23andMe/OAuth2Client(从 https://github.com/nxtbgthng/OAuth2Client 分叉)使用此客户端。

    这是一个适用于 Mac OS X 和 iOS(Cocoa 和 Cocoa touch)的 OAuth2 库。

    其实OAuth2.0是一个标准级别的协议,大部分公司的OAuth2.0服务接口也是标准的。

    【讨论】:

      猜你喜欢
      • 2018-03-29
      • 1970-01-01
      • 1970-01-01
      • 2019-11-22
      • 2010-12-26
      • 1970-01-01
      • 1970-01-01
      • 2020-03-04
      • 2011-06-19
      相关资源
      最近更新 更多