This repository contains two part
- Authorization UI to handle redirection from the Supabase OAuth endpoint (/auth/v1/oauth/authorize). The redirection happens automatically when the client app gets the OAuth endpoint. This Authorization UI is responsible for both showing user some UI for logging in, asking for consent, as well as handle (approve) the authorization
- A Client App that uses the OAuth2.1 server for authorization
For more details, please check out my blog Supabase As OAuth2.1 Server With ZERO lines of Server-Side Code!
- Go to database.new and click on that New project button to create a new Supabase project.
- Head to the Project's Dashboard, select Authentication > OAuth Server, and enable the Supabase OAuth 2.1 Server
- Make sure the authorization path is
/oauth/consent - In the
Auth URL Configuration,
set the site url to be
http://localhost:5173 - Register an OAuth client under Authentication > OAuth Apps. Set the redirect
URL to be
http://localhost:3000/oauth-callbackand note down the client ID. - Create a
.env.localwithin the AuthUI folder with the following variables
VITE_SUPABASE_URL=https://your_project_id.supabase.co
VITE_SUPABASE_PUBLISHABLE_KEY=sb_publishable_xxxxxx- Set up the oauth configurations parameters for Client App in
main.tsx
- Run
npm run devwithin AuthUI folder to start the Auth UI for the OAuth server listening tohttp://localhost:5173 - Run
npm run devwithin Client App folder to start the Client App for the OAuth server listening tohttp://localhost:3000 - Open
http://localhost:3000to sign in using the OAuth server
