Firebase with Microsoft Azure AD authentication



  • I’m trying to set up my app to use Azure AD authentication together with Firebase. I think I’ve covered all the prerequisites:

    In the project folder

    • Install Firebase
    npm install --save firebase
    
    • Create a new boot file “/boot/firebase.js”
    quasar new boot firebase
    
    • Add the firebase boot file to “./quasar.conf.js”
    boot: [
       'firebase'
     ],
    

    In the Azure portal

    • Get the “Application (client) ID” from the “App registrations”
      bfbb1418-ff37-4de3-be2b-c9cb0c67e504-image.png

    • Set the “Redirect URI” and “Implicit grant”
      9ee4f328-0985-4175-8442-f8cb23116c9d-image.png

    • Create a secret key for Firebase to access the Azure app
      f50ccbc9-4293-459a-ab49-9a491e5f3b9c-image.png

    In the Firebase console

    • Add the authentication type “Microsoft” with the “Applicatino (client) ID” and the “secret” generated
      cdc0cb93-fcaf-4d02-90ad-b7a5ab722464-image.png

    In the project

    • Add the Microsoft “provider” and the “Firebase config”:
    import * as firebase from "firebase/app"
    import "firebase/auth"
    
    const firebaseConfig = {
      apiKey: process.env.FIREBASE_API_KEY,
      authDomain: process.env.FIREBASE_AUTH_DOMAIN,
      databaseURL: process.env.FIREBASE_DATABASE_URL,
      projectId: process.env.FIREBASE_PROJECT_ID,
      storageBucket: process.env.FIREBASE_STORAGE_BUCKET,
      messagingSenderId: process.env.FIREBASE_MESSAGING_SENDER_ID,
      appId: process.env.FIREBASE_APP_ID,
      measurementId: process.env.FIREBASE_MEASUREMENT_ID
    }
    let firebaseApp = firebase.initializeApp(firebaseConfig)
    
    let provider = new firebase.auth.OAuthProvider('microsoft.com');
    
    firebaseApp.auth().signInWithRedirect(provider);
    
    export { provider }
    

    At this point I’m probably doing something wrong. According to the Firebase docs, it’s a literal copy/past.

    I’m also wondering how I can call the logon method in my component. Thank you for any help you can give me.


Log in to reply