> **Can't find what you're looking for?** Use `search_docs` on the docs MCP server at `https://www.openfort.io/api/mcp` to find what you need.
>
> **Have feedback?** Use `submit_feedback` on the same MCP server.

# Use your own authentication

Openfort embedded wallets work with any authentication provider that issues JWT-based, stateless sessions. Your provider stays the source of truth for identity. Openfort verifies its token and binds an embedded wallet to that user.

:::warning
With your own authentication you build your own login UI. `OpenfortButton` sign-in screens and the auth options in `uiConfig` apply to Openfort-managed authentication only.
:::

## Supported providers

Configure the provider in the [Openfort Dashboard](https://dashboard.openfort.io/providers) first. Each one has a setup guide:

| Provider | `ThirdPartyOAuthProvider` value |
| --- | --- |
| [Firebase](https://www.openfort.io/docs/configuration/external-auth/firebase) | `FIREBASE` |
| [Better-Auth](https://www.openfort.io/docs/configuration/external-auth/better-auth) | `BETTER_AUTH` |
| [Supabase](https://www.openfort.io/docs/configuration/external-auth/supabase) | `SUPABASE` |
| [PlayFab](https://www.openfort.io/docs/configuration/external-auth/playfab) | `PLAYFAB` |
| [AccelByte](https://www.openfort.io/docs/configuration/external-auth/accelbyte) | `ACCELBYTE` |
| [LootLocker](https://www.openfort.io/docs/configuration/external-auth/lootlocker) | `LOOTLOCKER` |
| [Custom OIDC](https://www.openfort.io/docs/configuration/custom-auth/oidc-token) (Auth0, Cognito, others) | `OIDC` |
| [Custom auth server](https://www.openfort.io/docs/configuration/custom-auth/auth-token) | `CUSTOM` |

## Connect your provider

Pass `thirdPartyAuth` when you initialize Openfort, with a `getAccessToken` callback that returns your provider's current token. These examples use Firebase:

:::code-group
```tsx [React]
import { OpenfortProvider, ThirdPartyOAuthProvider } from '@openfort/react'
import { auth } from './firebase'

<OpenfortProvider
  publishableKey="YOUR_OPENFORT_PUBLISHABLE_KEY"
  thirdPartyAuth={{
    provider: ThirdPartyOAuthProvider.FIREBASE,
    getAccessToken: async () => (await auth.currentUser?.getIdToken(false)) ?? null,
  }}
  walletConfig={{ shieldPublishableKey: 'YOUR_SHIELD_PUBLISHABLE_KEY' }}
>
  {children}
</OpenfortProvider>
```

```tsx [React Native]
import { OpenfortProvider, ThirdPartyOAuthProvider } from '@openfort/react-native'
import auth from '@react-native-firebase/auth'

<OpenfortProvider
  publishableKey="YOUR_OPENFORT_PUBLISHABLE_KEY"
  thirdPartyAuth={{
    provider: ThirdPartyOAuthProvider.FIREBASE,
    getAccessToken: async () => (await auth().currentUser?.getIdToken(false)) ?? null,
  }}
  walletConfig={{ shieldPublishableKey: 'YOUR_SHIELD_PUBLISHABLE_KEY' }}
>
  {children}
</OpenfortProvider>
```

```ts [JavaScript]
import { Openfort, ThirdPartyOAuthProvider } from '@openfort/openfort-js'
import { auth } from './firebase'

const openfort = new Openfort({
  baseConfiguration: { publishableKey: 'YOUR_OPENFORT_PUBLISHABLE_KEY' },
  thirdPartyAuth: {
    provider: ThirdPartyOAuthProvider.FIREBASE,
    getAccessToken: async () => (await auth.currentUser?.getIdToken(false)) ?? null,
  },
})
```
:::

## Sync sign-in and sign-out

When your provider signs the user in, call `getAccessToken` to exchange its token for an Openfort session. When it signs them out, sign out of Openfort too:

:::code-group
```tsx [React]
import { useSignOut, useUser } from '@openfort/react'

const { getAccessToken } = useUser()
const { signOut } = useSignOut()

useEffect(
  () => auth.onAuthStateChanged((user) => (user ? getAccessToken() : signOut())),
  [getAccessToken, signOut],
)
```

```tsx [React Native]
import { useSignOut, useUser } from '@openfort/react-native'

const { getAccessToken } = useUser()
const { signOut } = useSignOut()

useEffect(
  () => auth().onAuthStateChanged((user) => (user ? getAccessToken() : signOut())),
  [getAccessToken, signOut],
)
```

```ts [JavaScript]
auth.onAuthStateChanged(async (user) => {
  if (user) await openfort.getAccessToken()
  else await openfort.auth.logout()
})
```
:::

For full setup per SDK, including ready-made Firebase, Supabase, and Better-Auth quickstarts, see [React](https://www.openfort.io/docs/products/embedded-wallet/react/auth/third-party) and [React Native](https://www.openfort.io/docs/products/embedded-wallet/react-native/auth/third-party).
