Firebase custom authentication with Microsoft Azure / Graph
09:09 02 Nov 2017

I'm building an enterprise application using Microsoft Graph to sign in. After a successful signing, I want to use the token to be sent to authenticate to Firebase authentication (so I can secure the access to the database).

The token received after a successful sign in cannot be used directly to Firebase.

On the Firebase custom authentication instructions page, it says:

Get your project's server keys:

  1. Go to the Service Accounts page in your project's settings.

  2. Click Generate New Private Key at the bottom of the Firebase Admin SDK section of the Service Accounts page.

  3. The new service account's public/private key pair is automatically saved on your computer. Copy this file to your authentication server.

The third point says that you need to enter the key to the authentication server. Is this possible using Microsoft Graph or Azure AD?

The key that Firebase gives you is a JSON file. I've checked the Microsoft application registration portal which allows you to edit the application's Manifest, but without any luck.

The JSON file looks like this:

{
    "type": "service_account",
    "project_id": "APP_ID",
    "private_key_id": "KEY_ID_VALUE",
    "private_key": "-----BEGIN PRIVATE KEY---------END PRIVATE KEY-----\n",
    "client_email": "firebase-adminsdk-0ubvc@********.iam.gserviceaccount.com",
    "client_id": "XXXXXXXXXXXX",
    "auth_uri": "https://accounts.google.com/o/oauth2/auth",
    "token_uri": "https://accounts.google.com/o/oauth2/token",
    "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
    "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-0ubvc%XXXXXXXX.iam.gserviceaccount.com"
}

I can't seem to find any GitHub projects or Stack Overflow threads that covers this issue.

How can you receive custom tokens with MS Graph or Azure AD?

firebase-authentication azure-active-directory microsoft-graph-api