执行:
- (void)viewDidLoad { [super viewDidLoad]; GPPSignIn *aGPSSignIn = [GPPSignIn sharedInstance]; aGPSSignIn.scopes = @[ kGTLAuthScopePlusLogin,kGTLAuthScopePlusUserinfoEmail,kGTLAuthScopePlusUserinfoProfile,kGTLAuthScopePlusMe]; aGPSSignIn.shouldFetchGoogleUserEmail = YES; aGPSSignIn.shouldFetchGooglePlusUser =YES; aGPSSignIn.homeServerClientID = kClientID; aGPSSignIn.clientID = kClientID; aGPSSignIn.delegate = self; if (![aGPSSignIn trySilentAuthentication]) { [self showLoginButton]; } } - (void)showLoginButton { if (!self.signInButton) { self.signInButton = [GPPSignInButton buttonWithType:UIButtonTypeCustom]; [self.signInButton setFrame:CGRectMake(60,100,200,40)]; } [self.view addSubview:self.signInButton]; } #pragma mark - GPPSignInDelegate - (void)finishedWithAuth: (GTMOAuth2Authentication *)auth error: (NSError *) error { NSString *anAccessToken = auth.accessToken; NSLog(@"googleAccessToken:%@",anAccessToken); } - (void)didDisconnectWithError:(NSError *)iError { if (iError) { NSLog(@"Error:%@",iError); } }
注意: – (BOOL)应用程序:(UIApplication *)应用程序openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication注释:(id)注释在AppDelegate中处理.
问题:
>当用户点击Google SignIn按钮并导航到Safari时,Google登录状态很好.在我的应用程序中收到有效的AccessToken.
>但是,如果Google应用程序在iPhone上可用,那么用户将被导航到Google应用,但是在登录时不会接收到AccessToken.我得到一个错误.
错误:
Received error Error Domain=com.google.GooglePlusPlatform Code=-1 “The
operation couldn’t be completed. (com.google.HTTPStatus error 400.)”
UserInfo=0x15d95f90 {NSLocalizedDescription=The operation couldn’t be
completed. (com.google.HTTPStatus error 400.)} and auth object (null)
如果有人可以指导我解决这个问题,这将是非常有帮助的.
谢谢.
解决方法
脚步:
> Login your developer account
>选择你的项目
>选择API&从边栏的auth
>选择凭据
>复制’REDIRECT URIS’和’BUNDLE ID’
> Oen Xcode项目
>选择项目目标
>选择’信息’
>展开网址类型
>将“BUNDLE ID”粘贴到“标识符”区域
>粘贴URL方案区域中的’REDIRECT URIS’
如果它不工作,尝试用’BUNDLE ID’替换’REDIRECT URIS’,即标识符和URL方案是一样的.
希望这可以帮助你
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。