Third-party auth providers
Openfort's embedded wallets are fully-compatible with any authentication provider that supports JWT-based, stateless authentication.
First, follow the guide on how to configure third party authentication.
The supported authentication providers are ACCELBYTE
, CUSTOM
, FIREBASE
, SUPABASE
, LOOTLOCKER
, PLAYFAB
and OIDC
.
To authenticate with a third-party provider, set up the thirdPartyAuth
configuration when initializing Openfort
.
openfortConfig.ts
import { Openfort, ThirdPartyOAuthProvider } from '@openfort/openfort-js';
const openfort = new Openfort({
baseConfiguration: {
publishableKey: "YOUR_OPENFORT_PUBLISHABLE_KEY",
},
thirdPartyAuth: {
provider: ThirdPartyOAuthProvider.FIREBASE,
getAccessToken: async () => {
return (await auth.currentUser?.getIdToken(/* forceRefresh */ false)) ?? null
},
}
});
export default openfort;
Then, use the getAccessToken
method after logging in, and logout
when signing out.
This method exchanges a token from your authentication provider for an Openfort session.
For example, using Firebase:
auth.tsx
import openfort from "./openfortConfig";
import { auth } from "./firebaseConfig";
auth.onAuthStateChanged(async (user) => {
if (user) {
// User is signed in
await openfort.getAccessToken();
} else {
// User is signed out
await openfort.auth.logout();
}
});