I'm trying to integrate the GoogleSignIn framework in an iOS app and also authenticate an user on a server. I managed to log in the user, but in the - (void)signIn:(GIDSignIn *)signIn didSignInForUser:(GIDGoogleUser *)user withError:(NSError *)error delegate method, user.serverAuthCode is nil, and I need to pass this server authentication code to, uhm, authenticate the user on the server.
I read this documentation page and it states that I have to set the serverClientID property of the [GIDSignIn sharedInstance], but nowhere is it stated where do I find this "server client id". I ran tests with all the keys in the world to no avail.
I then found out this documentation page which looks like it's trying to tell us where to find this magical id, but it's using poor wording and didn't help. I do have OAuth2 credentials with type Web application, but:
Did anyone manage to successfully escape from the Google (poor) documentation's clutches?
You need to make sure [GIDSignIn sharedInstance].serverClientID property is set; the value can be found in Google API Console.
Also, if you got user.serverAuthCode with nil value, make sure you called [[GIDSignIn sharedInstance] signOut]; before any subsequent attempts. Otherwise [GIDSignIn sharedInstance] seems to remember previous configuration.
I have no problem getting the serverAuthCode in the simulator.
Try NOT running it in the simulator :)
Had the same problem. GIDSignIn.sharedInstance().serverClientID is the same as GIDSignIn.sharedInstance().clientID.
Solved by setting serverClientId too.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With