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

Kyo Kurosagi picture Kyo Kurosagi · Feb 28, 2019 · Viewed 8.4k times · Source

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);
    }      
}

Answer

Eren picture Eren · Aug 4, 2020

In my case; i got rid of this error when i turned off "Is App Secret embedded in the client?" in: Facebook for developers -> Settings -> Advanced.

Note: This option is visible if "Native or desktop app?" is enabled.