FB login - Firebase.Auth() Error: The supplied auth credential is malformed or has expired

社会主义新天地 提交于 2019-12-12 12:00:57

问题


I'm using react-native-fbsdk: 0.8.0, react-native-firebase: ^5.2.2, react-native: ^0.57.4 and Facebook Test User account.

This happened so suddenly. Once I sign out from firebase and try to log in again with Facebook.

Error: The supplied auth credential is malformed or has expired. [ Remote site 5XX from facebook.com for USER_INFO ].

I had tried AccessToken.refreshCurrentAccessTokenAsync(). But give me Error: Failed to refresh access token.

The Facebook token will expire in 60 days. Checked the token expired date is Apr 29, 2019. Change the test user account password and re-login again, still the same.

Is there anything I need to do in facebook or firebase setting?

const result = await LoginManager.logInWithReadPermissions(["public_profile","email"]);

if (result.isCancelled) {
  this.setState({isLoading : false});
  Alert.alert('Error','Login cancelled. Please try again');
} else {              
  try{
    await AccessToken.refreshCurrentAccessTokenAsync();
  }catch(err){
    this.setState({isLoading : false});
    console.log('ereee',err);
  }

  const data = await AccessToken.getCurrentAccessToken();        
  var credential = firebase.auth.FacebookAuthProvider.credential(data.accessToken);
  console.log(data.accessToken);
  //here I get expired date is 2019 April 29
  console.log(moment(data.expirationTime).toDate());

  firebase.auth().signInWithCredential(credential)
    .then((usercredential)=>{                  
      if (usercredential){       
      }else{
        this.setState({isLoading : false});
      }
    })
    .catch((error) => {  
      console.log(error);
    }      
}

回答1:


It is probably not helpful for OP as question is old but today I had exactly the same issue when implementing 3rd party login with Firebase and this question popped up as top result on the Google.

I had the same error message during implementation of GitHub login. The issue was on my side as I wrongly copied API and secret API keys.

Double check your keys and make sure you didn't copy anything extra like I did (it had extra space + extra word).




回答2:


I had the same issue, when it turned out I forgot to set the correct API keys and secret in the Firebase console (Authentication methods).



来源:https://stackoverflow.com/questions/54922944/fb-login-firebase-auth-error-the-supplied-auth-credential-is-malformed-or-h

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!