ios google登录的一些记录

首先:服务器需要authcode.
所以,需要配合服务器。

在- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {中
。。。
    [GIDSignIn sharedInstance].delegate = self;
    [GIDSignIn sharedInstance].clientID = [MacroKey kGoogleSignInClient_ID];
    [GIDSignIn sharedInstance].serverClientID = [MacroKey kGoogleSignInserverClientID_ID];

    [GIDSignIn sharedInstance].language = @"ch";
。。。。
}

[GIDSignIn sharedInstance].serverClientID 这个是服务器用到的。
[GIDSignIn sharedInstance].clientID 这个是app用到的。

如果没有按照规定的话,是拿不到用户的user.serverAuthCode


// The sign-in flow has finished and was successful if |error| is |nil|.
- (void)signIn:(GIDSignIn *)signIn
didSignInForUser:(GIDGoogleUser *)user
     withError:(NSError *)error{
    debugmethod();

    NSLog(@"user.authentication.accessToken ==>%@",user.authentication.accessToken);
    NSLog(@"serverAuthCode ==>%@",user.serverAuthCode);


    if (user.serverAuthCode) {

        [self dualwithGoogleLoginAuthcode:user.serverAuthCode];
    }

}

报错会:


image.png

custom scheme URIs are not allowed for 'WEB' client type

最后服务器拿到的authcode 后就可以做很多事情了。

全部评论

相关推荐

_mos_:要不是看评论区我都不知道你要找的是数分
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务