Car*_*izz 4 node.js ios 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];
}
}
Run Code Online (Sandbox Code Playgroud)
finishedWithAuth: 返回以下错误:
json={
error = "invalid_audience";
"error_description" = "The audience client and the client need to be in the same project.";
}}
Run Code Online (Sandbox Code Playgroud)
什么是受众?我们如何将客户端 ID 添加到我们的服务器?
谢谢!
这意味着您的 iOS 客户端 ID 和 Web/服务器客户端 ID 没有匹配的项目编号。客户端 ID 设置如下:
${PROJECT_NUMBER}-${ID_HASH}.apps.googleusercontent.com
Run Code Online (Sandbox Code Playgroud)
解决此问题的一种方法是重新创建客户端 ID。