eipipuz eipipuz - 21 days ago 6
iOS Question

How to set up iOS Google Sign In with backend integration?

I'm trying to follow the instructions at: https://developers.google.com/identity/sign-in/ios/offline-access. Whenever I send a token I get: "redirect_uri_mismatch".

I read in another question that client ids need to wait for a bit. This is not the case. The backend id has been active since August. The web app works fine. The server json sets "redirect_uris" to "postmessage".

This looks very similar to the question: Cross-platform Google OAuth Signin: redirect_uri mismatch but my scenario is with iOS and Go.

If I add a scope "audience:server:client_id:" as suggested by https://developers.google.com/identity/protocols/CrossClientAuth I get an "invalid scope" error.

Answer

I found the way.

First, forget about "audience:server:client_id:".

    let signin = GIDSignIn.sharedInstance()
    signin.clientID = "XXXX-YYYY.apps.googleusercontent.com"
    signin.serverClientID = "XXXX-ZZZZ.apps.googleusercontent.com"
    signin.scopes.append("https://www.googleapis.com/auth/plus.me")
    signin.delegate = self

Second, redirect_uris don't matter.

Last, the only thing else that you need to be careful is that serverAuthCode will only come once. So be sure to GIDSignIn.sharedInstance().signOut if you support log out.

Comments