I'm trying to use oauth2 to get data from 23 and me, but keep getting "bad request" codes. This is my first time working with OAuth2 and I'm not sure what I'm doing wrong.
When I use AFOAuth2Client, I get error code 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);
}];
The error block is hit with this message:
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}
When I try GTMOauth2Sample, I get invalid_client error after the authorization screen dismisses.
What am I doing wrong?