Unity Playfab:使用 Google 帐户登录(点击一次)而不是 Google Play 游戏

问题描述 投票:0回答:0

我有一个使用 Playfab 的 Unity 项目。 当我按下按钮时,我想使用 Google 帐户(点击一次)登录。我搜索了一些想法,但它总是使用谷歌玩游戏登录。

This is the desired result.

我试过:

void InitializePlayGamesLogin()
    {
        var config = new PlayGamesClientConfiguration.Builder()
            // Requests an ID token be generated.  
            // This OAuth token can be used to
            // identify the player to other services such as Firebase.
            .RequestServerAuthCode(false)
            .RequestEmail()
            .AddOauthScope("profile")
            .Build();

        PlayGamesPlatform.InitializeInstance(config);
        PlayGamesPlatform.DebugLogEnabled = true;
        PlayGamesPlatform.Activate();
    }

    public void LoginGoogle()
    {
        Social.localUser.Authenticate(OnGoogleLogin);
       
    }

    void OnGoogleLogin(bool success)
    {
        if (success)
        {
            string authCode = PlayGamesPlatform.Instance.GetServerAuthCode();
            authCodeTxt.SetText(authCode);
            PlayFabClientAPI.LoginWithGoogleAccount(new LoginWithGoogleAccountRequest()
            {
                TitleId = PlayFabSettings.TitleId,
                ServerAuthCode = authCode,
                CreateAccount = true
            }, (result) =>
            {
                status.SetText("Signed in as " + result.PlayFabId);
            }, OnPlayfabError
            );
        }
        else
        {
            status.SetText("Unsuccessful login");
        }
    }

    private void OnPlayfabError(PlayFab.PlayFabError playFabError)
    {
        status.SetText("Error "+ playFabError.GenerateErrorReport());       
    }

但它使用 Google Play Games 登录。

unity3d google-one-tap
© www.soinside.com 2019 - 2024. All rights reserved.