The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
docs: build a supabase integration.
thorwebdevfee68209c0f7
diff --git a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.tsindex 71029382f99..66179adaece 100644--- a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts+++ b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts@@ -1094,12 +1094,8 @@ export const platform: NavMenuConstant = {url: '/guides/platform/marketplace',},{- name: 'Publish an OAuth App',- url: '/guides/platform/oauth-apps/publish-an-oauth-app',- },- {- name: 'Sign in with Supabase',- url: '/guides/platform/oauth-apps/authorize-an-oauth-app',+ name: 'Build a Supabase Integration',+ url: '/guides/platform/oauth-apps/build-a-supabase-integration',},],},diff --git a/apps/docs/pages/guides/platform/oauth-apps/authorize-an-oauth-app.mdx b/apps/docs/pages/guides/platform/oauth-apps/build-a-supabase-integration.mdxsimilarity index 53%rename from apps/docs/pages/guides/platform/oauth-apps/authorize-an-oauth-app.mdxrename to apps/docs/pages/guides/platform/oauth-apps/build-a-supabase-integration.mdxindex 3a83e3c41a1..d288c48fe68 100644--- a/apps/docs/pages/guides/platform/oauth-apps/authorize-an-oauth-app.mdx+++ b/apps/docs/pages/guides/platform/oauth-apps/build-a-supabase-integration.mdx@@ -1,20 +1,34 @@import Layout from '~/layouts/DefaultGuideLayout'export const meta = {- id: 'authorize-an-oauth-app',- title: 'Authorize an OAuth App (Beta)',- description: 'Authorize an OAuth App',+ id: 'build-a-supabase-integration',+ title: 'Build a Supabase Integration (Beta)',+ description: 'Build a Supabase Integration using OAuth2 and the Management API.',}## Overview-This guide steps through implementing **Sign-in with Supabase**. Once you've added OAuth2.0 support to your main application, you will receive an access and refresh token from your users that choose to **Sign in with Supabase** on your application.+This guide steps through building a Supabase Integration using OAuth2 and the management API, allowing you to manage users' organizations and projects on their behalf.-The access token returned will grant your application full access to the [Management API](https://supabase.com/docs/reference/api/introduction) on behalf of the user.+Using OAuth2.0 you can retrieve an access and refresh token that grant your application full access to the [Management API](https://supabase.com/docs/reference/api/introduction) on behalf of the user.++## Create an OAuth App++1. In your organization's settings, navigate to the [**OAuth Apps**](/dashboard/org/_/apps) tab.+2. In the upper-right section of the page, click **Add application**.+3. Fill in the required details and click **Confirm**.++## Show a "Connect Supabase" button++In your backend, add a "Connect Supabase" button to kick off the OAuth2 flow utilizing the following design language.++// TODO add design guidelines## Implement the OAuth 2.0 flow-Once 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.+Once you've published your OAuth App on Supabase, you can use the OAuth 2.0 protocol get authorization from Supabase users to manage their organizations and projects.++You can use your preferred OAuth2 client or follow the steps below. You can see an example implementation in TypeScript using Supabase Edge Functions [on our GitHub](https://github.com/supabase/supabase/tree/master/examples/edge-functions/supabase/functions/connect-supabase).1. 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` A UUID uniquely identifying your OAuth app in Supabase.@@ -22,7 +36,7 @@ Once you've published your OAuth App on Supabase, you can use the OAuth 2.0 prot- `scope` The only scope supported is `all`. Scoped access is not available at this time.- `response_type` The value `code`.- `state` Information about the state of your app. 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.+ - 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 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.@@ -42,7 +56,30 @@ If the user has revoked access to your application, you will not be able to refr## Access the Management API using the access token-Refer to [this section](/docs/reference/api/introduction#authentication) to learn more about authentication with the Management API.+Refer to [the Management API reference](/docs/reference/api/introduction#authentication) to learn more about authentication with the Management API.++### Use the JavaScript (TypeScript) SDK++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.++## Intergation Options++There are a couple common patterns we recommend adding to your integration that can facilitate a great user experience.++### Store API keys in env variables++### Pre-fill database connection details++### Create a new project++### Configure custom Auth SMTP++You can configure the user's [custom SMTP settings](https://supabase.com/docs/guides/auth/auth-smtp) using the [`/config/auth` endpoint](https://api.supabase.com/api/v1#/projects%20config/updateV1AuthConfig).++## Current limitations++- No scopes support yet. Scoped (e.g. read-only) access will be supported in the future.+- We don't return database passwords via the API.export const Page = ({ children }) => <Layout meta={meta} children={children} />diff --git a/apps/docs/pages/guides/platform/oauth-apps/publish-an-oauth-app.mdx b/apps/docs/pages/guides/platform/oauth-apps/publish-an-oauth-app.mdxdeleted file mode 100644index 734cea523f3..00000000000--- a/apps/docs/pages/guides/platform/oauth-apps/publish-an-oauth-app.mdx+++ /dev/null@@ -1,25 +0,0 @@-import Layout from '~/layouts/DefaultGuideLayout'--export const meta = {- id: 'publish-an-oauth-app',- title: 'Publish an OAuth App (Beta)',- description: 'Publish an OAuth App',-}--## Overview--This guide steps through publishing an OAuth app under your organization.--## Publishing an OAuth App--1. In your organization's settings, navigate to the [**OAuth Apps**](/dashboard/org/_/apps) tab.-2. In the upper-right section of the page, click **Add application**.-3. In "Application name", fill in the name of your OAuth app.-4. In "Website URL", fill in the URL of the app that's using the OAuth app.-5. Upload a logo for your OAuth app.-6. In "Authorization callback URLs", add the callback URL of your app.-7. At the bottom of the page, click **Confirm**.--export const Page = ({ children }) => <Layout meta={meta} children={children} />--export default Pagediff --git a/apps/www/lib/redirects.js b/apps/www/lib/redirects.jsindex 3bac4663636..684508d7d4a 100644--- a/apps/www/lib/redirects.js+++ b/apps/www/lib/redirects.js@@ -2246,4 +2246,14 @@ module.exports = [source: '/docs/guides/integrations/zuplo',destination: '/partners/integrations/zuplo',},+ {+ permanent: true,+ source: '/docs/guides/platform/oauth-apps/publish-an-oauth-app',+ destination: '/docs/guides/platform/oauth-apps/build-a-supabase-integration#',+ },+ {+ permanent: true,+ source: '/docs/guides/platform/oauth-apps/authorize-an-oauth-app',+ destination: '/docs/guides/platform/oauth-apps/build-a-supabase-integration',+ },]