Build a Supabase Marketplace Integration
Supabase offers an OAuth2 connection flow and a Management API allowing you to build Supabase Marketplace Integrations that connect to our users' hosted Supabase projects, making it more convenient than ever to create scalabale backends programmatically and tap into the extensive pool of Supabase users.
Setup
- Follow the steps in the docs to create an OAuth App.
- Set
SUPA_CONNECT_CLIENT_IDandSUPA_CONNECT_CLIENT_SECRETin your.env.localfile as shown in the.env.local.examplefile.
Connect to Supabase using OAuth2
This example showcases and end-to-end OAuth2 connection flow with PKCE, with the following steps:
- Create authorization URL with PKCE codeVerifier.
- Redirect user to Supabase to authorize your application to connect to their Supabase account.
- User gets redirected to the callback route, where we exchange the code in the URL for
access_tokenandrefresh_token. - We use the
access_tokento retrieve a list of the user's projects using thesupabase-management-jslibrary.
Run locally
supabase functions serve connect-supabase --no-verify-jwt --env-file ./supabase/.env.local
Navigate to http://localhost:54321/functions/v1/connect-supabase
Deploy to Supabase Edge Functions
supabase functions deploy connect-supabase --no-verify-jwt
supabase secrets set --env-file ./supabase/.env.local