如何使用Unity 3d获取谷歌访问令牌?

时间:2017-04-20 10:23:53

标签: c# unity3d access-token

干草即时使用统一3d登录与谷歌+我做得正确现在我想获得访问令牌登录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()始终为null 任何帮助PLZ 谢谢。

1 个答案:

答案 0 :(得分:0)

在某些版本的GPGS插件中检索访问令牌似乎存在问题。您应该能够使用服务器访问代码而不是访问令牌解决此问题。尝试替换

.SetAccessToken(PlayGamesPlatform.Instance.GetIdToken())

.SetCode(PlayGamesPlatform.Instance.GetServerAuthCode())