Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

invalid_grant when using hybrid flow on a Mac Catalyst app #13

Open
Nyshiki opened this issue Feb 4, 2020 · 3 comments
Open

invalid_grant when using hybrid flow on a Mac Catalyst app #13

Nyshiki opened this issue Feb 4, 2020 · 3 comments

Comments

@Nyshiki
Copy link

Nyshiki commented Feb 4, 2020

Hi,
I use the hybrid flow to perform the Sign-in with Google on a Mac Catalyst app. I generate the authorization code on the client and exchange it on the server to obtain access and refresh token.

The redirect to the app after the sign in through custom scheme works fine and I'm able to obtain the authorization code.

@IBAction func login() {
    do {
          try GAppAuth.shared.authorize(in: self) { auth in
                if auth {
                    if GAppAuth.shared.isAuthorized() {
                        let authorization = GAppAuth.shared.getCurrentAuthorization()

                        sendAuthCodeToServer(serverAuthCode: authorization?.authState.lastAuthorizationResponse.authorizationCode, userName: authorization?.userEmail, userEmail: authorization?.userEmail)
                    }
                }
            }
        } catch let error {
            print(error.localizedDescription)
        }
}

But when I share the authorization code with my server, I get an error on the request to exchange the authentication code to obtain access_token and refresh_token.
400 {'error': 'invalid_grant', 'error_description': 'Bad Request'}

Please note that that I'm able to exchange the authorization code with access_token and refesh_token on the device.

Any ideas on what's wrong and how can I fix this?

I suspect there's something that Google libraries for login do that is not implemented in GAppAuth (see openid/AppAuth-Android#293).

@girishw
Copy link

girishw commented Feb 27, 2020

Facing the same issue.

@elsesiy
Copy link
Owner

elsesiy commented Mar 8, 2020

Unfortunately I have no idea on how to proceed here. I'm just wrapping whatever the GTMAppAuth pod does so I suspect the same issue would be happening over there..

@girishw
Copy link

girishw commented Mar 23, 2020

@elsesiy It looks like the Google libraries are using a proprietary extension of OID. More information here:

openid/AppAuth-Android#107
https://stackoverflow.com/questions/45325768/google-sign-in-using-appauth-and-cross-client-identity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants