question

jcoriston avatar image
jcoriston asked

Google login issues not using GPGS for Unity not working consistently? Code already redeemed

I'm trying to implement sign in with google, and to an extent I have. I've been using this plugin https://www.assetstore.unity3d.com/en/#!/content/94517 to get the authentication info for google including the server auth code and sending that to playfab. The plugin's google login works fine and when I send it to playfab it usually works the first time as well. But after attempting it one more time the playfab link/login fails consistently with the error invalid_grant: code already redeemed.


I start by generating an account with the android device id. When the user clicks the login button my flow is the following : Get Server Auth Code->Attempt to link google account->Log in with google account if successful or if another account linked to that google account exists->unlink android device if link was successful.

I also make sure to save the server auth code when the user launches the app again. Though I doubt this is the issue because I did try not saving it, and I still ended up with the same issues. The Server Auth Code does appear to be a different string each time as well.

Account ManagementAuthenticationandroid
10 |1200

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

1 Answer

·
brendan avatar image
brendan answered

The only way you should get the "code already redeemed" response is if you're re-using a ServerAuthCode, so I'd double-check the flow.

Speaking of which though, can you clarify the flow in the second paragraph above? It sounds like you're saying you do a login call after a link call. But to make a link call successfully, you have to already be signed in, so another login would be superfluous. What's the actual sequence of calls, in your title?

3 comments
10 |1200

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

jcoriston avatar image jcoriston commented ·

Alright thanks! I fixed it

I was doing a login call after a link call because it was easier since I needed the account info of the user, so I just redirected them to the login call that was used if they already had an account. I also implemented facebook login, and that's what I did for that and it seemed to work fine since facebook access tokens don't get consumed. But with google, I was generating a new server auth code for each login, but I never generated a new one for the link, and that's what was causing the problem.

0 Likes 0 ·
brendan avatar image brendan ♦♦ jcoriston commented ·

Why not just call Client/GetAccountInfo, GetPlayerCombinedInfo, or GetPlayerProfile to get the info after the link operation?

0 Likes 0 ·
jcoriston avatar image jcoriston brendan ♦♦ commented ·

That's what I'm doing now

0 Likes 0 ·

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.