Firebase身份验证错误:auth / invalid-credential

时间:2019-07-12 16:41:06

标签: javascript firebase authentication firebase-authentication

我已经尝试使用firebase提供的身份验证服务超过2周。一切都运转良好,直到昨天,对于我来说,我无法使用facebook auth提供程序,也无法使用Twitter来使用户连接到我的Web应用程序。

我尝试退出并登录,删除了我的facebook和twitter应用程序,并使用其他帐户创建了其他应用程序,问题仍然存在。

当我尝试使用以前在他们的github上提供的代码时,发生了相同的问题。

奇怪的是,当我使用google provider或使用电子邮件和密码登录方式时,它工作正常。

PS:我确保在控制台中启用了提供程序。

const signInWithFacebookButton = document.getElementById('signInWithFacebook');

const auth = firebase.auth();

const signInWithFacebook = () => {

  const facebookProvider = new firebase.auth.FacebookAuthProvider();

  auth.signInWithPopup(facebookProvider)
  .then(() => {
    console.log('Successfully signed in');
  })
  .catch(error => {
    console.error(error);
  })
}

signInWithFacebookButton.addEventListener('click', signInWithFacebook);

当我尝试使用facebook进行身份验证时出现错误消息:

{code: "auth/invalid-credential", message: "The supplied auth credential is malformed or has expired."}

当我尝试使用Twitter进行身份验证时出现错误消息:

{code: "auth/invalid-credential", message: "Error getting request token: 403 <?xml version="1.…ode-project-fd88e.firebaseapp.com/__/auth/handler"}

2 个答案:

答案 0 :(得分:0)

对于Twitter登录,错误代码403指示客户端禁止访问URL。由于您必须将回调URL(您的网站)列入白名单,因此会出现此类错误。因此,在Twitter应用设置中,您必须添加网址,例如 https://sitename.example.com/auth/twitterhttps://sitename.example.com/auth/twitter/callback

有关更多详细信息,请参阅此社区文章: Twitter callback URLs

答案 1 :(得分:0)

这是值得回答的问题:在复制并将其粘贴到Firebase设置控制台之前,请始终单击以显示您的Facebook应用程序机密。这是违反直觉的,但是Facebook没有正确实现剪贴板,因此隐藏的星号字符将被逐字复制并粘贴。

相关问题