首页 > 解决方案 > Realm React-Native Auth0:提供的凭据无效或用户不存在

问题描述

我开始使用 Realm 不久,我正在尝试使用各种教程和文档在我的 RN 应用程序中集成身份验证工作流程。(到目前为止,我一直在使用昵称提供程序)。

所以目前,从应用程序中,我可以点击登录,设置我的电子邮件/密码,该用户将被发送到 auth0。但我无法将该用户添加到我的领域。并继续出现该错误:

"{"type":" https://docs.realm.io/server/troubleshoot/errors#invalid-credentials ","title":"提供的凭据无效或用户不存在。","status" :401,"detail":"jwt 格式错误","code":611}"

这是我的登录功能:

login = () => {
  auth0.webAuth
    .authorize({
      scope: Config.AUTHO_SCOPE,
      audience: Config.AUTH0_AUDIENCE,
      device: DeviceInfo.getUniqueID(),
      prompt: "login"
    })
    .then(res => {
      console.log("res: ")
      console.log(res)
      auth0.auth
        .userInfo({
          token: res.accessToken
        })
        .then(data => {
          //Error is here
          const user = Realm.Sync.User.login(SERVER_URL, Realm.Sync.Credentials.jwt(res.accessToken))
          this.onAuthenticated(data);
        })
        .catch(err => {
          console.log("err: ");
          console.log(JSON.stringify(err));
        });

      SInfo.setItem("accessToken", res.accessToken, {});
      SInfo.setItem("refreshToken", res.refreshToken, {});
    })
    .catch(error => {
      console.log("error occurrdzz");
      console.log(error);
    });
};

我确定我犯了错误,我认为我没有得到使身份验证工作的所有步骤..

无论如何,谢谢大家的帮助,我希望我已经足够精确了!

标签: react-nativeauthenticationrealmauth0

解决方案


推荐阅读