【发布时间】: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