Sign In Register

How can we help you today?

Start a new topic

Authenticating with google play tutorial (Unity3d)

since i was stuck on this issue for about a week here is the solution to how to authenticate with google play.


1.create new web app link in google play console

set LaunchURL to https://www.gamesparks.com/ and click ok


2.once configured go to your api console once there click edit on web application and change Authorized redirect URIs from https://www.gamesparks.com/oauth2callback to
http://www.gamesparks.com/oauth2callback


3.configure gamesparks integration

set google app id (this can be found in google play console)

set Google Application Client ID to your web app client id don't put your android client id or it will not work

set Google Application Client Secret to your web app client secret


4.open unity and navigate to google play games android configuration and in client id field paste your web app client id


5.initialize google play games

 PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder()
            .RequestServerAuthCode(false)
            .Build();
        PlayGamesPlatform.InitializeInstance(config);
        PlayGamesPlatform.Activate();

        Social.localUser.Authenticate(success => { });

6.gamesparks authentication

 

note! redirect uri must be the same in your code and in your api console or you will get NOTAUTHENTICATED error

string displayName = PlayGamesPlatform.Instance.GetUserDisplayName();
        string AuthCode = PlayGamesPlatform.Instance.GetServerAuthCode();

        new GooglePlayConnectRequest()
        .SetCode(AuthCode)
        .SetRedirectUri("http://www.gamesparks.com/oauth2callback")
        .SetDisplayName(displayName)
        .Send((googleplayAuthResponse) =>
        {
            if (!googleplayAuthResponse.HasErrors)
            {
                Debug.Log("GameSparks Authenticated!");
            }
            else
            {
                Debug.Log(googleplayAuthResponse.Errors.JSON);
            }
        }
        );

 

 

 

1 Comment

Thanks for the info. Does this actually work for you? I just followed the same steps (but for Android not Unity) and I still get NOTAUTHENTICATED response. I feel like there is an issue in GameSparks call to google server asking to exchange ServerAuthCode for an AccessToken...


1 person likes this
Login to post a comment