question

jonathanjarri avatar image
jonathanjarri asked

/Client/LoginWithGoogleAccount: Google API error code: invalid_grant details: Bad Request

Hello everyone,

I'm currently facing an issue trying to login using a Google's server auth code with the PlayFab LoginWithGoogleAccount API call, but I have this error message:

/Client/LoginWithGoogleAccount: Google API error code: invalid_grant details: Bad Request

There is a lot of steps to make Google authentication works as expected and I've already solved a lot of issues, but I don't understand what happens with this one.

This error only appears after I've linked the account to PlayFab, if I try to login to a PlayFab account linked to Google using a server auth code I've just got from the Google authentication, it works as expected.

The problem is I would like to login with a stored Google's server auth code at my game launch, and it's like the server auth code is not valid anymore when I link the Google account to PlayFab...

My actual flow looks like that:

1. The player launches the app and login with device ID

2. The player chooses to login with Google => we retrieve the server auth code

3. The player chooses to link its current PlayFab account to Google => we store the server auth code in the preferences

4. The player closes and relaunches the app

5. The app detect a Google server auth code exists and try to login using PlayFab API's LoginWithGoogleAccount => invalid_grant details: Bad Request

As said above:

- if I call LoginWithGoogleAccount after the step 2 (and a PF account is already linked to this Google account), it works.

- if I call LoginWithGoogleAccount after the step 3 it doesn't work with the same error => invalid_grant details: Bad Request

Do you know what happen?

apisAuthentication
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

v-humcin avatar image
v-humcin answered

The server auth code is a one time use code so you would not want to store and reuse it. Whenever the local user is authenticated upon starting the game you can request a new server auth code.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

emreedemir avatar image
emreedemir answered

Do you solve problem??

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

abhishekkhunt avatar image
abhishekkhunt answered

same problem

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

arda avatar image
arda answered

Try using`if (Social.localUser.authenticated) PlayGamesPlatform.Instance.SignOut();` before trying to login if you get this error. It solved my problem. Note: Don't use "true" on .RequestServerAuthCode(forceRefreshToken) when building PlayGames. It only works when it's "false"

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.