簡體   English   中英

如何使用unity 3d獲取Google訪問令牌?

[英]how to get google access token using unity 3d?

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()始終為null,請幫助。謝謝。

在某些版本的GPGS插件中檢索訪問令牌似乎存在問題。 您應該能夠通過使用服務器訪問代碼而不是訪問令牌來解決此問題。 嘗試更換

.SetAccessToken(PlayGamesPlatform.Instance.GetIdToken())

.SetCode(PlayGamesPlatform.Instance.GetServerAuthCode())

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM