0

我正在尝试通过 AFOAuth2Client(AFNetworking 扩展)登录 Google +。我写了这段代码:

NSURL *url = [NSURL URLWithString:@"https://accounts.google.com/"];
AFOAuth2Client *oauthClient = [AFOAuth2Client  clientWithBaseURL:url clientID:@"MY_ID" secret:@"MY_SECRET"];

[oauthClient authenticateUsingOAuthWithPath:@"/o/oauth2/token"
                                     parameters:@{@"scope": @"https://www.googleapis.com/auth/plus.me", @"response_type" : @"code", @"redirect_uri" : @"https://www.domain.com/oauth2callback"}
                                        success:^(AFOAuthCredential *credential) {
        NSLog(@"I have a token! %@", credential.accessToken);
    } failure:^(NSError *error) {
        NSLog(@"Error: %@", error);
    }];

但是使用 invalid_request 调用错误块(错误 400)。我错过了什么吗?(缺少参数?)

4

1 回答 1

0

请仔细查看OAuth2 文档,代码中的参数是错误的。scope 应该是 openid 或 email,并且缺少其他参数。

于 2013-08-12T15:31:11.907 回答