服务器应该如何代表iOS用户进行身份验证?

时间:2014-09-08 19:14:50

标签: ios node.js google-oauth

我使用google-api-nodejs-client获取个人资料信息并使用Google登录。我希望iOS客户端通过我的服务器登录Google。

- (void)finishedWithAuth:(GTMOAuth2Authentication *)auth error:(NSError *)error {
    if (error) {
        NSLog(@"Error: %@", error);

        abort();
    } else {
        NSString *serverCode = [GPPSignIn sharedInstance].homeServerAuthorizationCode;
        NSURLRequest * urlRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://localhost:1337/auth/google/callback?code=%@",serverCode]]];
        NSURLResponse * response = nil;
        NSError * error = nil;
        [NSURLConnection sendSynchronousRequest:urlRequest
                                              returningResponse:&response
                                                          error:&error];
        NSLog(@"%@, %@",[response description], serverCode);


        [self refreshInterface];
    }
}

finishedWithAuth:返回以下错误:

json={
    error = "invalid_audience";
    "error_description" = "The audience client and the client need to be in the same project.";
}}

观众是什么以及如何将客户端ID添加到我们的服务器?

谢谢!

1 个答案:

答案 0 :(得分:4)

这意味着您的iOS客户端ID和Web /服务器客户端ID没有匹配的项目编号。客户端ID设置如下:

${PROJECT_NUMBER}-${ID_HASH}.apps.googleusercontent.com

解决此问题的一种方法是重新创建客户端ID。

相关问题