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 后就可以做很多事情了。

