The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Update apps/docs/pages/guides/integrations/oauth-apps/authorizing-an-oauth-app.mdx
Kang Ming8278242f3aac
diff --git a/apps/docs/pages/guides/integrations/oauth-apps/authorizing-an-oauth-app.mdx b/apps/docs/pages/guides/integrations/oauth-apps/authorizing-an-oauth-app.mdxindex 0385ba344cb..012d3e7cbef 100644--- a/apps/docs/pages/guides/integrations/oauth-apps/authorizing-an-oauth-app.mdx+++ b/apps/docs/pages/guides/integrations/oauth-apps/authorizing-an-oauth-app.mdx@@ -16,19 +16,23 @@ The access token returned will grant your application full access to the [ManageOnce you've published your OAuth App on Supabase, you can use the OAuth 2.0 protocol to seek consent from Supabase users to access their organization or project.-1. Call the [`GET /v1/oauth/authorize`](<https://api.supabase.com/api/v1#/oauth%20(beta)/authorize>) endpoint. This should redirect the user to a consent screen where they can select the organization that they want to grant access to.-- > Note: `redirect_uri` and `state` combined must not be larger than 4kB. PKCE is strongly recommended for security reasons.--2. Ensure that your application server has implemented the endpoint listed in the "Authorization callback URLs". After the user consents to your application receiving access, your application server will receive a `GET` request on the provided `redirect_uri` in the previous step. This `redirect_uri` will contain the following query parameters:-- `code` : A unique authorization code you can exchange for a Supabase access and refresh token.-- `state` : (Optional) The state you passed to the [`GET /v1/oauth/authorize`](<https://api.supabase.com/api/v1#/oauth%20(beta)/authorize>) endpoint previously.--3. Extract these query parameters and exchange the `code` using the [`POST /v1/oauth/token`](<https://api.supabase.com/api/v1#/oauth%20(beta)/token>) endpoint.--4. An access token and refresh token will be returned if the request is successful.+1. Within your app's UI, redirect the user to [`https://api.supabase.io/v1/oauth/authorize`](<https://api.supabase.com/api/v1#/oauth%20(beta)/authorize>). Make sure to include all required query parameters such as:+ - `client_id` A UUID uniquely identifying your OAuth app in Supabase.+ - `redirect_uri` The URL where Supabase will redirect the user after providing consent.+ - `scope` The value `all` as scoped access is not available at this time.+ - `response_type` Only `code` is allowed at this time.+ - `state` Any extra state you wish echoed back to the `redirect_uri`. Note that `redirect_uri` and `state` cannot both exceed 4kB in size.+ - We strongly recommend using the PKCE flow for increased security. Generate a random value before taking the user to the authorize endpoint. This value is called code verifier. Hash it with SHA256 and include it as the `code_challenge` parameter, while setting `code_challenge_method` to `s256`. In the next step, you would need to provide the code verifier to get the first access and refresh token.+2. Once the user consents to providing API access to your OAuth App, Supabase will redirect the user to the `redirect_uri` endpoint you provided in the previous step. The URL will additionally contain these query parameters:+ - `code` An authorization code you should exchange with Supabase to get the access and refresh token.+ - `state` The value you provided in the previous step, to help you associate the request with the user.+3. Exchange the authorization code for an access and refresh token by calling `POST https://api.supabase.com/v1/oauth/token` and including the following query parameters:+ - `grant_type` The value `authorization_code`.+ - `code` The authorization code.+ - `client_id` The unique client ID identifying your OAuth App.+ - `client_secret` The secret that authenticates your OAuth App to Supabase.+ - `redirect_uri` This must be exactly the same URL used in the first step.+ - If you used the PKCE flow in the first step, include the code verifier as `code_verifier`.## Refresh an access token