通过Google Play游戏进行Firebase身份验证

时间:2018-12-12 14:36:11

标签: android firebase unity3d firebase-authentication google-play-games

我想通过Google Play游戏使用身份验证,但是总是在第二次登录或链接请求(第一次成功)后获得:

  

Firebase.FirebaseException:发生内部错误。 [从GOOGLE_PLAY_GAMES获取访问令牌时出错,OAuth2重定向uri是:http://localhost,响应:OAuth2TokenResponse {params:error = invalid_grant&error_description = Bad%20Request,httpMetadata:HttpMetadata {status = 400,cachePolicy = NO_CACHE,cacheDuration = null,cacheImmate = false,staleWhileRevalidate =空,文件名=空,lastModified =空,标头= HTTP / 1.1 200 OK,cookieList = []}}]

删除用户后,登录名将再次正常运行。 我应该在firebase控制台中设置一些内容来解决此问题吗?

验证GPG脚本

Error: Can't find Python executable "C:\Program Files\Python30\", you can set the PYTHON env variable.

基于身份验证调用:

    public void Init()
    {
        PlayGamesHelperObject.CreateObject();

        PlayGamesHelperObject.RunOnGameThread(() =>
        {
            PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder()
                .RequestServerAuthCode(false)
                .Build();

            PlayGamesPlatform.DebugLogEnabled = true;

            PlayGamesPlatform.InitializeInstance(config);
            Social.Active = PlayGamesPlatform.Activate();
        });
    }

    public void Authenticate(Action<bool, ILocalUser, string> onAuth)
    {
        if (Social.localUser == null)
        {   
            onAuth.Invoke(false, Social.localUser, string.Empty);
            return;
        }
        if (Social.localUser.authenticated)
        {
            onAuth.Invoke(true, Social.localUser, PlayGamesPlatform.Instance.GetServerAuthCode());
            return;
        }

        PlayGamesHelperObject.RunOnGameThread(() =>
        {
            Social.Active.Authenticate(Social.localUser, (status)=>
            {
                onAuth.Invoke(status, Social.localUser, PlayGamesPlatform.Instance.GetServerAuthCode());
            });
        });
    }

GoogleAuth类的一部分:

    private FirebaseUser User { get; set; }
    private GoogleAuth Auth { get; set; }

    event Action<Exception> onSingInFailed = delegate { };
    event Action<FirebaseUser> onSignInSocials = delegate { };
    event Action<FirebaseUser> onLinkInSocials = delegate { };

    public void OnSocialsLogin(bool status, ILocalUser user, string authCode)
    {
        if(status)
        {
            Credential credential = PlayGamesAuthProvider.GetCredential(authCode);

            if (User == null)
                Auth.SignInWithCredential(credential, onSignInSocials, onSingInFailed);
            else
                Auth.LinkWithCredential(User, credential, onLinkInSocials, (exc) =>
                {
                    onLinkFailed.Invoke(exc);
                    Auth.SignInWithCredential(credential, onSignInSocials, onSingInFailed);
                });
       }
    }

0 个答案:

没有答案