question

Juan Felipe Medrano avatar image
Juan Felipe Medrano asked

Authentication with google play services errors.

Hello, I'm currently trying to implement authentication with google play services. I have followed this setup, but got stuck on an error.

After installing the test app on an android device and trying the google sign in option, I get the following error at first:

"redirect_uri_mismatch" or "GoogleOAuthError".

If I try agin after this first error, I get the folowing error:


"invalid_grant details: Bad Request"

This is the code to intialize Google:

PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder()
AddOauthScope("profile")
.RequestServerAuthCode(false)
.Build();

PlayGamesPlatform.InitializeInstance(config);
PlayGamesPlatform.DebugLogEnabled = true;
PlayGamesPlatform.Activate();

And this is the code to link or login with google:

Social.localUser.Authenticate((bool success) =>
        {
            if (success)
            {
                var ServerAuthCode = PlayGamesPlatform.Instance.GetServerAuthCode();
                if (PlayFabClientAPI.IsClientLoggedIn())
                {
                    PlayfabLinkGoogleAccount(ServerAuthCode);
                }
                else
                {
                    
                    PlayfabSignInWithGoogle(ServerAuthCode);
                }
               
            }
        });

From there i just pass the Playfab API passing on the server auth code.

Why is this happening?

apisAuthenticationgame manager
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

·
Sarah Zhang avatar image
Sarah Zhang answered

Have you viewed the “important” text box in this section - Configuring Google Play Games? As the “important” tip said, you should change the default authorized redirect URI to https://oauth.playfab.com/oauth2/google. Otherwise, you will get the mismatch redirect_uri error. Could you please confirm that you have set up the correct authorized redirect URIs?

1 comment
10 |1200

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

Juan Felipe Medrano avatar image Juan Felipe Medrano commented ·

Hey, Thank you for your response, it led me to fix the issue.

The documentation is outdated and I couldn't find the place where the "Important tip" was taking place inside the Google Play Console. After some digging I finally found where it is but is not apparently clear since the "Linked Apps" section is now missing. this section should be updated to prevent future errors when implementing google authentication.

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.