Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

feat: more recommendations.

thorwebdev1558cc504c68
diff --git a/apps/docs/pages/guides/platform/oauth-apps/build-a-supabase-integration.mdx b/apps/docs/pages/guides/platform/oauth-apps/build-a-supabase-integration.mdx
index a3e7ebec72d..a97d60c2cc9 100644
--- a/apps/docs/pages/guides/platform/oauth-apps/build-a-supabase-integration.mdx
+++ b/apps/docs/pages/guides/platform/oauth-apps/build-a-supabase-integration.mdx
@@ -32,12 +32,12 @@ You can use your preferred OAuth2 client or follow the steps below. You can see
Within your app's UI, redirect the user to [`https://api.supabase.com/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` Your client id from the app creation above.
-- `redirect_uri` The URL where Supabase will redirect the user to after providing consent.
-- `scope` Currently only `all` is supported. More fine grained scopes coming soon.
-- `response_type` Set this to `code`.
-- `state` Information about the state of your app. Note that `redirect_uri` and `state` together cannot 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.
+- `client_id`: Your client id from the app creation above.
+- `redirect_uri`: The URL where Supabase will redirect the user to after providing consent.
+- `scope`: Currently only `all` is supported. More fine grained scopes coming soon.
+- `response_type`: Set this to `code`.
+- `state`: Information about the state of your app. Note that `redirect_uri` and `state` together cannot exceed 4kB in size.
+- (Recommended) PKCE: 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.
```ts
router.get('/connect-supabase/login', async (ctx) => {
@@ -58,22 +58,22 @@ Find the full example on [GitHub](https://github.com/supabase/supabase/tree/mast
### Handle the callback
-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 contain these query parameters:
+Once the user consents to providing API access to your OAuth App, Supabase will redirect the user to the `redirect_uri` provided in the previous step. The URL will 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. The `state` property returned here should be compared to the `state` you sent previously.
+- `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. The `state` property returned here should be compared to the `state` you sent previously.
-Exchange the authorization code for an access and refresh token by calling [`POST https://api.supabase.com/v1/oauth/token`](<https://api.supabase.com/api/v1#/oauth%20(beta)/token>) and including the following query parameters as content-type `application/x-www-form-urlencoded`:
+Exchange the authorization code for an access and refresh token by calling [`POST https://api.supabase.com/v1/oauth/token`](<https://api.supabase.com/api/v1#/oauth%20(beta)/token>) with the following query parameters as content-type `application/x-www-form-urlencoded`:
-- `grant_type` The value `authorization_code`.
-- `code` The `code` returned in the previous step.
-- `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`.
+- `grant_type`: The value `authorization_code`.
+- `code`: The `code` returned in the previous step.
+- `redirect_uri`: This must be exactly the same URL used in the first step.
+- (Recommended) `code_verifier`: If you used the PKCE flow in the first step, include the code verifier as `code_verifier`.
-As per OAuth2 spec, provide the client id and client secret as basic auth headers:
+As per OAuth2 spec, provide the client id and client secret as basic auth header:
-- `client_id` The unique client ID identifying your OAuth App.
-- `client_secret` The secret that authenticates your OAuth App to Supabase.
+- `client_id`: The unique client ID identifying your OAuth App.
+- `client_secret`: The secret that authenticates your OAuth App to Supabase.
```ts
router.get('/connect-supabase/oauth2/callback', async (ctx) => {
@@ -112,7 +112,7 @@ You can use the [`POST /v1/oauth/token`](<https://api.supabase.com/api/v1#/oauth
If the user has revoked access to your application, you will not be able to refresh a token. Furthermore, access tokens will stop working. Make sure you handle HTTP Unauthorized errors when calling any Supabase API.
-## Access the Management API using the access token
+## Call the Management API
Refer to [the Management API reference](/docs/reference/api/introduction#authentication) to learn more about authentication with the Management API.
@@ -120,15 +120,37 @@ Refer to [the Management API reference](/docs/reference/api/introduction#authent
For convenience, when working with JavaScript/TypeScript, you can use the [supabase-management-js](https://github.com/supabase-community/supabase-management-js#supabase-management-js) library.
-## Integration Options
+```ts
+import { SupabaseManagementAPI } from 'supabase-management-js'
+
+const client = new SupabaseManagementAPI({ accessToken: '<access token>' })
+```
+
+## Integration Recommendations
-There are a couple common patterns we recommend adding to your integration that can facilitate a great user experience.
+There are a couple common patterns you can consider adding to your integration that can facilitate a great user experience.
### Store API keys in env variables
+Some integraions, e.g. like [Cloudflare Workers](/partners/integrations/cloudflare-workers) provide convenient access to the API URL and API keys to allow user to speed up development.
+
+Using the management API, you can retrieve a project's API credentials using the [`/projects/{ref}/api-keys` endpoint](https://api.supabase.com/api/v1#/projects/getProjectApiKeys).
+
### Pre-fill database connection details
-### Create a new project
+If your integration directly connects to the project's database, you can pref-fill the Postgres connection details for the user, it follows this schema:
+
+```
+postgresql://postgres:[DB-PASSWORD]@db.[REF].supabase.co:5432/postgres
+```
+
+Note that you cannot retrieve the database password via the management API, so for the user's existing projects you will need to collect their database password in your UI.
+
+### Create new organizations and projects
+
+If you don't need access to the user's existing project, we recommend creating a new project under a new organization. Use the [`/v1/organizations` endpoint](https://api.supabase.com/api/v1#/organizations/createOrganization) to create a new organization named after your integration, afterward use the [`/v1/projects` endpoint](https://api.supabase.com/api/v1#/projects/createProject) to create a new project.
+
+When creating a new project, you can either ask the user to provide a database password, or you can generate a secure password for them. In any case, make sure to securely store the database password on your end which will allow you to construct the Postgres URI.
### Configure custom Auth SMTP