【问题标题】:Firebase Authentication Unity3d. The supplied auth credential is malformed or has expiredFirebase 身份验证 Unity3d。提供的身份验证凭据格式错误或已过期
【发布时间】:2021-01-04 21:42:50
【问题描述】:

我正在尝试在 Unity3d 应用程序中使用 Facebook 提供程序实现 Firebase 身份验证。

Unity 版本 2020.2.0f1 火力基地 7.0.2 脸书 8.1.1

这是我的代码。

private void Awake()
    {
        if (!FB.IsInitialized)
        {
            FB.Init(InitCallback, OnApplicationPause);
        }
        else
        {
            FB.ActivateApp();
        }
    }


    public void FBLogin()
    {
        var permissions = new List<string> {
        "public_profile",
        "gaming_profile",
        "email",
    };
        FB.LogInWithReadPermissions(permissions, AuthCallback);
    }

    private void AuthCallback(ILoginResult result)
    {
        if (result.Error != null)
        {
            Debug.LogFormat("Facebook SDK error: {0}", result.Error);
        }
        else if (FB.IsLoggedIn)
        {
            var aToken = AccessToken.CurrentAccessToken;

            foreach (string permission in aToken.Permissions)
            {
                Debug.Log(permission);
            }
            Debug.Log(" " + aToken.TokenString);
            Services.GetManager<FirebaseAuthService>().SugnUpFB(aToken.TokenString);

        }
        else
        {
            Debug.Log("Facebook login was cancelled.");
        }
    }


    private void InitCallback()
    {
        if (FB.IsInitialized)
        {
            FB.ActivateApp();
        }
        else
        {
            Debug.Log("Failed FB SDK init.");
        }
    }


    private void OnApplicationPause(bool pauseStatus)
    {
        if (!pauseStatus)
        {
            if (FB.IsInitialized)
            {
                FB.ActivateApp();
            }
            else
            {
                FB.Init(() => {
                    FB.ActivateApp();
                });
            }
        }
    }

Firebase 代码

public void SugnUpFB(string token)
    {
        Debug.Log("token " + token);

        Credential credential = FacebookAuthProvider.GetCredential(token);
        
        auth.SignInWithCredentialAsync(credential).ContinueWith(task =>
          {
              if (task.IsCanceled)
              {
                  Debug.LogError("SignInWithCredentialAsync was canceled.");
                  return;
              }
              if (task.IsFaulted)
              {
                  Debug.LogError("SignInWithCredentialAsync encountered an error: " + task.Exception);
                  return;
              }

              FirebaseUser newUser = task.Result;
              Debug.LogFormat("User signed in successfully: {0} ({1})",
                  newUser.DisplayName, newUser.UserId);
          });
    }

记录https://prnt.sc/wga2rr

我收到此错误https://prnt.sc/wg9xrr

我的脸书设置https://prnt.sc/wga527

凭据仅包含提供者字段。我认为这是一个问题https://prnt.sc/wg9zxv 我怎样才能解决这个问题? 谢谢!

【问题讨论】:

    标签: firebase facebook unity3d


    【解决方案1】:

    如果你使用的是 Graph API,那么它毫无意义 firebase Oauth 登录支持普通 Facebook 登录 但不是游戏的单独登录 the reason why

    【讨论】:

      猜你喜欢
      • 2019-12-17
      • 2020-05-07
      • 2021-07-08
      • 1970-01-01
      • 2020-09-26
      • 2019-07-22
      • 1970-01-01
      • 2022-11-11
      • 1970-01-01
      相关资源
      最近更新 更多