我正在尝试使用 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 错误。
我究竟做错了什么?