ios – Google Plus登录

ios – Google Plus登录,第1张

概述场景:通过Google登录登录到应用程序 执行: - (void)viewDidLoad { [super viewDidLoad]; GPPSignIn *aGPSSignIn = [GPPSignIn sharedInstance]; aGPSSignIn.scopes = @[ kGTLAuthScopePlusLogin, kGTLAuthScopePlusUse 场景:通过Google登录登录到应用程序

执行:

- (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)

如果有人可以指导我解决这个问题,这将是非常有帮助的.
谢谢.

解决方法 请在项目中设置URL方案.

脚步:

> Login your developer account
>选择你的项目
>选择API&从边栏的auth
>选择凭据
>复制’REDIRECT URIS’和’BUNDLE ID’
> Oen Xcode项目
>选择项目目标
>选择’信息’
>展开网址类型
>将“BUNDLE ID”粘贴到“标识符”区域
>粘贴URL方案区域中的’REDIRECT URIS’

如果它不工作,尝试用’BUNDLE ID’替换’REDIRECT URIS’,即标识符和URL方案是一样的.

希望这可以帮助你

总结

以上是内存溢出为你收集整理的ios – Google Plus登录全部内容,希望文章能够帮你解决ios – Google Plus登录所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1112517.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存