rembrembdocs

OAuth 2.1 Server


Supabase Auth can act as an OAuth 2.1 and OpenID Connect (OIDC) identity provider. This allows other applications and services to use your Supabase project as their authentication provider, just like "Sign in with Google" or "Sign in with GitHub".

You can use this to build "Sign in with [Your App]" experiences, authenticate AI agents through the Model Context Protocol (MCP), power developer platforms with third-party integrations, or implement standards-compliant enterprise SSO.

Use cases#

There are several reasons why you might want to enable OAuth 2.1 Server in your Supabase project:

Overview#

Supabase Auth implements the OAuth 2.1 authorization code flow with PKCE (Proof Key for Code Exchange). When a third-party application wants to access user data:

  1. The application redirects the user to your authorization endpoint
  2. Supabase Auth validates the request and redirects to your custom authorization UI
  3. The user authenticates (using any of your enabled auth methods) and approves access
  4. Supabase Auth issues an authorization code
  5. The application exchanges the code for access and refresh tokens
  6. The application uses the access token to make authenticated API requests

Access tokens are standard Supabase JWTs that include user_id, role, and client_id claims. Your existing Row Level Security policies automatically apply to OAuth tokens, giving you fine-grained control over what each client can access.

Supported standards#

Integration with existing auth#

OAuth 2.1 Server works seamlessly with your existing Supabase Auth configuration:

Set up OAuth 2.1 server#

To enable OAuth 2.1 Server in your project, follow these guides:

[

Getting Started

Enable OAuth 2.1, configure your authorization endpoint, and register your first client.

](getting-started/index.md)

[

OAuth Flows

Detailed walkthrough of authorization code and refresh token flows.

](oauth-flows/index.md)

[

MCP Authentication

Authenticate AI agents and LLM tools using Model Context Protocol.

](mcp-authentication/index.md)

[

Token Security & RLS

Control data access with Row Level Security policies for OAuth clients.

](token-security/index.md)

Resources#