简体   繁体   中英

how to get google access token using unity 3d?

hay im using unity 3d to login with google+ i did it correctly now i want to get access token to login with gamesparks but always the access token is null i dont know why and here is my code:

 public void GoogleSignIn()
{
    if (!signedin)
    {
        Social.localUser.Authenticate((bool success) =>
        {
            if (success)
            {

                Debug.Log("yes");

            }
            else
                Debug.Log("no");
        });
    }
}
  public void GooglePlaySignInWithGS()
{
    new GameSparks.Api.Requests.GooglePlusConnectRequest()
      .SetAccessToken(PlayGamesPlatform.Instance.GetIdToken())
      .SetDoNotLinkToCurrentPlayer(false)
      .SetSwitchIfPossible(true)
      .Send((Google_response) =>
      {
          if (!Google_response.HasErrors)
          {
              OnAuthentication(Google_response);
              Debug.Log("done");
          }
          else
          {
              Debug.LogWarning(Google_response.Errors.JSON);
          }
      });

}

getIdToken() always null any help plz thank you.

There seems to be an issue retrieving the access token in some version of the GPGS plugin. You should be able to work around this by using the server access code instead of the access token. Try replacing

.SetAccessToken(PlayGamesPlatform.Instance.GetIdToken())

with

.SetCode(PlayGamesPlatform.Instance.GetServerAuthCode())

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM