Add Single Sign-On to your Firebase application with WorkOS.
In this guide, you’ll learn how to use WorkOS to add Single Sign-On (SSO) to a Firebase app. We will use the logic in an existing WorkOS callback route to create a custom token and sign a user in with Firebase.
This guide uses the WorkOS and Firebase Node.js SDKs, for support with a different SDK please reach out to [email protected]
To get the most out of this guide, you should:
First, install the Firebase SDKs in the project directory:
Second, initialize your Firebase admin app.
In this guide we will use the IdP ID as the Firebase UID. Please use whatever UID best meets the needs of your application.
In the SSO setup guide you added a callback endpoint to call
The profile returned will have unique identifier for the user, assigned by the Identity Provider called the
We will use this to generate a custom JWT with Firebase.
In this step we will add onto the previous logic to create the Firebase custom JWT.
You will use the
createCustomToken(uid) method from the Firebase Admin SDK, with the IdP ID as the
Once the token in created you will use the
signInWithCustomToken(auth, customToken) method from the
firebase/auth SDK to authenticate the user.
Now that you’ve authenticated the user, you can update their Firebase profile with attributes in the profile returned from WorkOS.
You now have a Firebase user that is signed in and updated with SAML attributes.