简体   繁体   English

如何使用unity 3d获取Google访问令牌?

[英]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: hay im使用unity 3d登录google +我现在正确地做到了,我想获取访问令牌以使用gamesparks登录,但是访问令牌始终为null我不知道为什么,这是我的代码:

 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. getIdToken()始终为null,请帮助。谢谢。

There seems to be an issue retrieving the access token in some version of the GPGS plugin. 在某些版本的GPGS插件中检索访问令牌似乎存在问题。 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()) .SetAccessToken(PlayGamesPlatform.Instance.GetIdToken())

with

.SetCode(PlayGamesPlatform.Instance.GetServerAuthCode()) .SetCode(PlayGamesPlatform.Instance.GetServerAuthCode())

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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