How to use Microsoft Oauth using firebase

54 Views Asked by At

I'm trying to use firebase javascript SDK to authenticate using Microsoft AD/Oauth. I'm attempting to follow the instructions here but I'm running into problems. Right now with the following code

import { getAuth, signInWithPopup, OAuthProvider } from "firebase/auth";
import { initializeApp } from 'firebase/app';
const fireBaseAuthKey = 'my firebase web api key';
function microsoftOauth() {
  let p = new OAuthProvider('microsoft.com');
  const firebaseApp = initializeApp({ apiKey: fireBaseAuthKey });

  let auth = getAuth(firebaseApp);
  signInWithPopup(auth,p).then((r)=> {
    console.log(r);
  }).catch((err)=> {
    console.log(err);
  })
}

Please note that I can't figure out how to have getAuth() to work so that is why I put in the api key etc just to make sure i'm connected to the right google firebase app.

I get this error:

FirebaseError: Firebase: Error (auth/auth-domain-config-required).
    at createErrorInternal (firebase_auth.js?v=e270105d:636:37)
    at _assert (firebase_auth.js?v=e270105d:642:11)
    at getIframeUrl (firebase_auth.js?v=e270105d:6251:3)
    at _openIframe (firebase_auth.js?v=e270105d:6284:10)
    at async BrowserPopupRedirectResolver.initAndGetManager (firebase_auth.js?v=e270105d:6477:20)

I have done the following:

  1. Created an azure account
  2. Created an azure app registration
  3. Created the azure client secret
  4. Copied the client id and secret to the firebase console
  5. Copied the firebase redirect url and added that to the azure app
  6. I also added localhost, 127.0.0.1 to authorized domains in firebase
  7. I even deployed to my web server and added that domain and still no go.

I'm lost and need help. I'm hoping I'm doing something obviously stupid and someone can direct me. Please note that I did try and follow this example on stackoverflow and still no dice.

0

There are 0 best solutions below