Firebase Microsoft SignInWithCredential

Viewed 395

I am setting up Microsoft authentication in Firebase (web js sdk), but I'm running into an error with firebase.auth.signInWithCredential. I can successfully get an id token from Microsoft, but the Firebase auth step fails. I've tried Firebase v8 and v9, and various ways of forming my credential object. In fact, I get the same error even passing an access token. There seems to be something wrong with the Firebase library. Has anyone experienced this issue before and resolved it?

Code:

const { id_token } = authResponse.params; // I've verified that id_token is correct
const credential = new firebase.auth.OAuthProvider("microsoft.com").credential({
  idToken: id_token,
  rawNonce: "12345",
});
await firebase.auth().signInWithCredential(credential);

The credential seems to be generated fine:

Object {
  "accessToken": undefined,
  "idToken": "eyJ0eXAiOiJKV...",
  "nonce": "12345",
  "pendingToken": null,
  "providerId": "microsoft.com",
  "secret": undefined,
  "signInMethod": "microsoft.com",
}

But the signInWithCredential step gets the following error:

Uncaught (in promise) 
code: "auth/internal-error"
message: "Invalid IdP response/credential: http://localhost?id_token=eyJ0eXAiOiJKV..."
1 Answers
Related