The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
docs: update google auth docs (#38740)
Stojan Dimitrovskie09df40f939d
diff --git a/apps/docs/content/guides/auth/social-login/auth-google.mdx b/apps/docs/content/guides/auth/social-login/auth-google.mdxindex e73d62e6cf0..023aa782b00 100644--- a/apps/docs/content/guides/auth/social-login/auth-google.mdx+++ b/apps/docs/content/guides/auth/social-login/auth-google.mdx@@ -2,148 +2,124 @@id: 'auth-google'title: 'Login with Google'description: 'Use Sign in with Google on the web, in native apps or with Chrome extensions'-tocVideo: 'vojHmGUGUGc'----Supabase Auth supports Sign in with Google for the web, native Android applications, and Chrome extensions.+Supabase Auth supports [Sign in with Google for the web](https://developers.google.com/identity/gsi/web/guides/overview), native applications ([Android](https://developer.android.com/identity/sign-in/credential-manager-siwg), [macOS and iOS](https://developers.google.com/identity/sign-in/ios/start-integrating)), and [Chrome extensions](https://cloud.google.com/identity-platform/docs/web/chrome-extension).-## Prerequisites--- A Google Cloud project. Go to the [Google Cloud Platform](https://console.cloud.google.com/home/dashboard) and create a new project if necessary.+You can use Sign in with Google in two ways:-## Configuration+- [By writing application code](#application-code) for the web, native applications or Chrome extensions+- [By using Google's pre-built solutions](#google-pre-built) such as [personalized sign-in buttons](https://developers.google.com/identity/gsi/web/guides/personalized-button), [One Tap](https://developers.google.com/identity/gsi/web/guides/features) or [automatic sign-in](https://developers.google.com/identity/gsi/web/guides/automatic-sign-in-sign-out)-To support Sign In with Google, you need to configure the Google provider for your Supabase project.--<Tabs- scrollable- size="large"- type="underlined"- defaultActiveId="web"- queryGroup="platform"->- <TabPanel id="web" label="Web">--For web applications, you can set up your signin button two different ways:+## Prerequisites-- Use your own [application code](#application-code) for the button.-- Use [Google's pre-built sign-in or One Tap flows](#google-pre-built).+You need to do some setup to get started with Sign in with Google:-### Application code configuration+- Prepare a Google Cloud project. Go to the [Google Cloud Platform](https://console.cloud.google.com/home/dashboard) and create a new project if necessary.+- Use the [Google Auth Platform console](https://console.cloud.google.com/auth/overview) to register and set up your application's:+ - [**Audience**](https://console.cloud.google.com/auth/audience) by configuring which Google users are allowed to sign in to your application.+ - [**Data Access (Scopes)**](https://console.cloud.google.com/auth/scopes) define what your application can do with your user's Google data and APIs, such as access profile information or more.+ - [**Branding**](https://console.cloud.google.com/auth/branding) and [**Verification**](https://console.cloud.google.com/auth/verification) show a logo and name instead of the Supabase project ID in the consent screen, improving user retention. Brand verification may take a few business days.-To use your own application code:+### Setup required scopes-1. In the Google Cloud console, go to the [Consent Screen configuration page](https://console.cloud.google.com/apis/credentials/consent). The consent screen is the view shown to your users when they consent to signing in to your app.-1. Under **Authorized domains**, add your Supabase project's domain, which has the form `<PROJECT_ID>.supabase.co`.-1. Configure the following non-sensitive scopes:- - `.../auth/userinfo.email`- - `...auth/userinfo.profile`- - `openid`-1. Go to the [API Credentials page](https://console.cloud.google.com/apis/credentials).-1. Click `Create credentials` and choose `OAuth Client ID`.-1. For application type, choose `Web application`.-1. Under **Authorized JavaScript origins**, add your site URL.-1. Under **Authorized redirect URLs**, enter the callback URL from the [Supabase dashboard](/dashboard/project/_/auth/providers). Expand the Google Auth Provider section to display it.+Supabase Auth needs a few scopes granting access to profile data of your end users, which you have to configure in the [**Data Access (Scopes)**](https://console.cloud.google.com/auth/scopes) screen:- <Admonition type="tip">+- `openid` (add manually)+- `.../auth/userinfo.email` (added by default)+- `...auth/userinfo.profile` (added by default)- The redirect URL is visible to your users. You can customize it by configuring [custom domains](/docs/guides/platform/custom-domains).+If you add more scopes, especially those on the sensitive or restricted list your application might be subject to verification which may take a long time.- </Admonition>+### Setup consent screen branding-1. When you finish configuring your credentials, you will be shown your client ID and secret. Add these to the [Google Auth Provider section of the Supabase Dashboard](/dashboard/project/_/auth/providers).+<Admonition type="note">- Alternatively, you can configure Google authentication using the Management API:+It's strongly recommended you set up a custom domain and optionally verify your brand information with Google, as this makes phishing attempts easier to spot by your users.- ```bash- # First, get your access token from https://supabase.com/dashboard/account/tokens- export SUPABASE_ACCESS_TOKEN="your-access-token"- export PROJECT_REF="your-project-ref"+</Admonition>- # Update auth config to enable Google provider- curl -X PATCH "https://api.supabase.com/v1/projects/$PROJECT_REF/config/auth" \- -H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" \- -H "Content-Type: application/json" \- -d '{- "external_google_enabled": true,- "external_google_client_id": "your-google-client-id",- "external_google_secret": "your-google-client-secret"- }'- ```+Google's consent screen is shown to users when they sign in. Optionally configure the following to improve the appearance of the screen, increasing the perception of trust by your users:- <Admonition type="tip">+1. Set up a [custom domain for your project](/docs/guides/platform/custom-domains) to present the user with a clear relationship to the website they clicked Sign in with Google on.+ - A good approach is to use `auth.example.com` or `api.example.com`, if your application is hosted on `example.com`.+ - If you don't set this up, users will see `<project-id>.supabase.co` which does not inspire trust and can make your application more susceptible to successful phishing attempts.+1. Verify your application's brand (logo and name) by configuring it in the [Branding](https://console.cloud.google.com/auth/branding) section of the Google Auth Platform console. Brand verification is not automatic and may take a few business days.- In local development, you can add the client ID and secret to your `config.toml` file.+## Project setup- </Admonition>+To support Sign In with Google, you need to configure the Google provider for your Supabase project.-### Google pre-built configuration+<Tabs+ scrollable+ size="large"+ type="underlined"+ defaultActiveId="web"+ queryGroup="platform"+>+ <TabPanel id="web" label="Web">-To use Google's pre-built signin buttons:+Regardless of whether you use application code or Google's pre-built solutions to implement the sign in flow, you need to configure your project by obtaining a Client ID and Client Secret in the [Clients](https://console.cloud.google.com/auth/clients) section of the Google Auth Platform console:-1. In the Google Cloud console, go to the [Consent Screen configuration page](https://console.cloud.google.com/apis/credentials/consent). The consent screen is the view shown to your users when they consent to signing in to your app.-1. Configure the screen to your liking, making sure you add links to your app's privacy policy and terms of service.-1. Go to the [API Credentials page](https://console.cloud.google.com/apis/credentials).-1. Click `Create credentials` and choose `OAuth Client ID`.-1. For application type, choose `Web application`.-1. Under **Authorized JavaScript origins** and **Authorized redirect URLs**, add your site URL. This is the URL of the website where the signin button will appear, _not_ your Supabase project domain. If you're testing in localhost, ensure that you have `http://localhost` set in the **Authorized JavaScript origins** section as well. This is important when integrating with Google One-Tap to ensure you can use it locally.-1. When you finish configuring your credentials, you will be shown your client ID. Add this to the **Client IDs** field in the [Google Auth Provider section of the Supabase Dashboard](/dashboard/project/_/auth/providers). Leave the OAuth client ID and secret blank. You don't need them when using Google's pre-built approach.+1. [Create a new OAuth client ID](https://console.cloud.google.com/auth/clients/create) and choose **Web application** for the application type.+1. Under **Authorized JavaScript origins** add your application's URL. These should also be configured as the [Site URL or redirect configuration in your project](/docs/guides/auth/redirect-urls).+ - If your app is hosted on `https://example.com/app` add `https://example.com`.+ - Add `http://localhost:<port>` while developing locally. Remember to remove this when your application [goes into production](/docs/guides/deployment/going-into-prod).+1. Under **Authorized redirect URIs** add your Supabase project's callback URL.+ - Access it from the [Google provider page on the Dashboard](/dashboard/project/_/auth/providers?provider=Google).+ - For local development, use `http://localhost:3000/auth/v1/callback`.+1. Click `Create` and make sure you save the Client ID and Client Secret.+ - Add these values to the [Google provider page on the Dashboard](/dashboard/project/_/auth/providers?provider=Google).</TabPanel><TabPanel id="react-native" label="Expo React Native">- 1. Configure OAuth credentials for your Google Cloud project in the [Credentials](https://console.cloud.google.com/apis/credentials) page of the console. When creating a new OAuth client ID, choose _Android_ or _iOS_ depending on the mobile operating system your app is built for.- - For Android, use the instructions on screen to provide the SHA-1 certificate fingerprint used to sign your Android app.- - You will have a different set of SHA-1 certificate fingerprints for testing locally and going to production. Make sure to add both to the Google Cloud Console, and add all of the Client IDs to the Supabase dashboard.- - For iOS, use the instructions on screen to provide the app Bundle ID, and App Store ID and Team ID if the app is already published on the Apple App Store.- 2. Configure the [OAuth Consent Screen](https://console.cloud.google.com/apis/credentials/consent). This information is shown to the user when giving consent to your app. In particular, make sure you have set up links to your app's privacy policy and terms of service.- 3. Finally, add the client ID from step 1 in the [Google provider on the Supabase Dashboard](/dashboard/project/_/auth/providers), under _Client IDs_.-- Note that you do not have to configure the OAuth flow in the Supabase Dashboard in order to use native sign in.+1. [Create a new OAuth client ID](https://console.cloud.google.com/auth/clients/create) and choose **Android** or **iOS** depending on the OS you're building the app for.+ - For Android, use the instructions on screen to provide the SHA-1 certificate fingerprint used to sign your Android app.+ - You will have a different set of SHA-1 certificate fingerprints for testing locally and going to production. Make sure to add both to the Google Cloud Console, and add all of the Client IDs to the Supabase dashboard.+ - For iOS, use the instructions on screen to provide the app Bundle ID, and App Store ID and Team ID if the app is already published on the Apple App Store.+1. Register the Client ID in the [Google provider page on the Dashboard](/dashboard/project/_/auth/providers?provider=Google).</TabPanel>- <TabPanel id="flutter" label="Flutter">+ <TabPanel id="flutter-mobile" label="Flutter (iOS and Android)">++1. [Create a new OAuth client ID](https://console.cloud.google.com/auth/clients/create) and choose **Android** or **iOS** depending on the OS you're building the app for.+ - For Android, use the instructions on screen to provide the SHA-1 certificate fingerprint used to sign your Android app.+ - You will have a different set of SHA-1 certificate fingerprints for testing locally and going to production. Make sure to add both to the Google Cloud Console, and add all of the Client IDs to the Supabase dashboard.+ - For iOS, use the instructions on screen to provide the app Bundle ID, and App Store ID and Team ID if the app is already published on the Apple App Store.+1. Register the Client ID in the [Google provider page on the Dashboard](/dashboard/project/_/auth/providers?provider=Google).+ - For iOS enable the `Skip nonce check` option.++For iOS add a `CFBundleURLTypes` key in the `<project>/ios/Runner/Info.plist` file:++```xml+<!-- Put me in the [my_project]/ios/Runner/Info.plist file -->+<!-- Google Sign-in Section -->+<key>CFBundleURLTypes</key>+<array>+ <dict>+ <key>CFBundleTypeRole</key>+ <string>Editor</string>+ <key>CFBundleURLSchemes</key>+ <array>+ <!-- TODO Replace this value: -->+ <!-- Copied from GoogleService-Info.plist key REVERSED_CLIENT_ID -->+ <string>com.googleusercontent.apps.861823949799-vc35cprkp249096uujjn0vvnmcvjppkn</string>+ </array>+ </dict>+</array>+<!-- End of the Google Sign-in Section -->+```- ### iOS and Android+</TabPanel>- 1. Configure Web, Android, and iOS OAuth credentials. Follow the Platform integration instructions on the [README of google_sign_in package](https://pub.dev/packages/google_sign_in#platform-integration) for Android and iOS.- - For both Android and iOS, you will need to create a Web client ID in the [Google Cloud Console](https://console.cloud.google.com/apis/credentials).- - For Android, use the instructions on screen to provide the SHA-1 certificate fingerprint used to sign your Android app.- - You will have a different set of SHA-1 certificate fingerprint for testing locally and going to production. Make sure to add both to the Google Cloud Console. and add all of the Client IDs to Supabase dashboard.- - For iOS, use the instructions on screen to provide the app Bundle ID, and App Store ID and Team ID if the app is already published on the Apple App Store.- 2. Configure the [OAuth Consent Screen](https://console.cloud.google.com/apis/credentials/consent). This information is shown to the user when giving consent to your app. In particular, make sure you have set up links to your app's privacy policy and terms of service.- 3. Add only the web client ID from step 1 in the [Google provider on the Supabase Dashboard](/dashboard/project/_/auth/providers), under _Client IDs_. If you need iOS support, enable the `Skip nonce check` option.- 4. For iOS, add the `CFBundleURLTypes` attributes below into the `/ios/Runner/Info.plist` file.- ```xml- <!-- Put me in the [my_project]/ios/Runner/Info.plist file -->- <!-- Google Sign-in Section -->- <key>CFBundleURLTypes</key>- <array>- <dict>- <key>CFBundleTypeRole</key>- <string>Editor</string>- <key>CFBundleURLSchemes</key>- <array>- <!-- TODO Replace this value: -->- <!-- Copied from GoogleService-Info.plist key REVERSED_CLIENT_ID -->- <string>com.googleusercontent.apps.861823949799-vc35cprkp249096uujjn0vvnmcvjppkn</string>- </array>- </dict>- </array>- <!-- End of the Google Sign-in Section -->- ```-- ### Web, macOS, Windows, and Linux-- To use the OAuth 2.0 flow, you will require the following information:-- 1. Obtain OAuth credentials for your Google Cloud project in the [Credentials](https://console.developers.google.com/apis/credentials) page of the console. If you already have a web client ID, no need to create a new one. When creating a new credential, choose _Web application_. In _Authorized redirect URIs_ enter `https://<project-id>.supabase.co/auth/v1/callback`. This URL will be seen by your users, and you can customize it by configuring [custom domains](/docs/guides/platform/custom-domains).- 2. Configure the [OAuth Consent Screen](https://console.cloud.google.com/apis/credentials/consent). This information is shown to the user when giving consent to your app. Within _Authorized domains_ make sure you add your Supabase project's domain `<project-id>.supabase.co`. Configure the non-sensitive scopes by making sure the following ones are selected: `.../auth/userinfo.email`, `.../auth/userinfo.profile`, `openid`. If you're selecting other sensitive scopes, your app may require additional verification. In those cases, it's best to use [custom domains](/docs/guides/platform/custom-domains).- 3. Finally, add the client ID and secret from step 1 in the [Google provider on the Supabase Dashboard](/dashboard/project/_/auth/providers).+<TabPanel id="flutter-other" label="Flutter (web, macOS, Windows, Linux)">- </TabPanel>+Follow the same configuration guide as if your app was a Web application when building a desktop Flutter application.++</TabPanel><$Show if="sdk:swift">@@ -195,40 +171,53 @@ To use Google's pre-built signin buttons:<TabPanel id="android" label="Android (Kotlin)">- ### Using Google sign-in on Android-- 1. Configure OAuth credentials for your Google Cloud project in the [Credentials](https://console.cloud.google.com/apis/credentials) page of the console. You need two client IDs, a web client ID and Android client ID. When creating a new Android OAuth client ID, use the instructions on screen to provide the SHA-1 certificate fingerprint used to sign your Android app.- 2. Configure the [OAuth Consent Screen](https://console.cloud.google.com/apis/credentials/consent). This information is shown to the user when giving consent to your app. In particular, make sure you have set up links to your app's privacy policy and terms of service.- 3. Finally, add the web client ID from step 1 in the [Google provider on the Supabase Dashboard](/dashboard/project/_/auth/providers), under _Client IDs_.-- Note that you do not have to configure the OAuth flow in the Supabase Dashboard in order to use native sign in.+1. [Create a new OAuth client ID](https://console.cloud.google.com/auth/clients/create) and choose **Android** or **iOS** if also building an iOS app with Kotlin Multiplatform.+ - For Android, use the instructions on screen to provide the SHA-1 certificate fingerprint used to sign your Android app.+ - You will have a different set of SHA-1 certificate fingerprints for testing locally and going to production. Make sure to add both to the Google Cloud Console, and add all of the Client IDs to the Supabase dashboard.+ - For iOS (with Kotlin Multiplatform), use the instructions on screen to provide the app Bundle ID, and App Store ID and Team ID if the app is already published on the Apple App Store.+1. Register the Client ID in the [Google provider page on the Dashboard](/dashboard/project/_/auth/providers?provider=Google).- ### Using Google sign-in with Kotlin Multiplatform+ </TabPanel>- 1. Configure OAuth credentials for your Google Cloud project in the [Credentials](https://console.cloud.google.com/apis/credentials) page of the console. When creating a new OAuth client ID, choose _Android_ or _iOS_ depending on the mobile operating system your app is built for.+ <TabPanel id="chrome-extensions" label="Chrome Extensions">- - For Android, use the instructions on screen to provide the SHA-1 certificate fingerprint used to sign your Android app.- - For iOS, use the instructions on screen to provide the app Bundle ID, and App Store ID and Team ID if the app is already published on the Apple App Store.+1. [Create a new OAuth client ID](https://console.cloud.google.com/auth/clients/create) and choose **Chrome Extension** for application type.+ - Enter your extension's Item ID and optionally verify app ownership.+1. Register the Client ID in the [Google provider page on the Dashboard](/dashboard/project/_/auth/providers?provider=Google) under _Client IDs_.- 2. Configure the [OAuth Consent Screen](https://console.cloud.google.com/apis/credentials/consent). This information is shown to the user when giving consent to your app. In particular, make sure you have set up links to your app's privacy policy and terms of service.- 3. Finally, add the client ID from step 1 in the [Google provider on the Supabase Dashboard](/dashboard/project/_/auth/providers), under _Client IDs_.+ </TabPanel>+</Tabs>- Note that you do not have to configure the OAuth flow in the Supabase Dashboard in order to use native sign in.+### Local development- </TabPanel>+To use the Google provider in local development:- <TabPanel id="chrome-extensions" label="Chrome Extensions">+1. Add a new environment variable:+ ```env+ SUPABASE_AUTH_EXTERNAL_GOOGLE_CLIENT_SECRET="<client-secret>"+ ```+2. Configure the provider:+ ```toml+ [auth.external.google]+ enabled = true+ client_id = "<client-id>"+ secret = "env(SUPABASE_AUTH_EXTERNAL_GOOGLE_CLIENT_SECRET)"+ skip_nonce_check = false+ ```- You will need to configure a client ID for your Chrome extension:+If you have multiple client IDs, such as one for Web, iOS and Android, concatenate all of the client IDs with a comma but make sure the web's client ID is first in the list.- 1. Configure OAuth credentials for your Google Cloud project in the [Credentials](https://console.cloud.google.com/apis/credentials) page of the console. When creating a new OAuth client ID, choose _Chrome extension_ for the application type. For _Item ID_ provide the unique ID of your Chrome extension. You can get this by calling `chrome.runtime.id` within the extension, or from the Web Store URL of the extension. For example, the [Google Translate extension](https://chrome.google.com/webstore/detail/google-translate/aapbdbdomjkkjkaonfhkkikfgjllcleb) has the Web Store URL `https://chrome.google.com/webstore/detail/google-translate/aapbdbdomjkkjkaonfhkkikfgjllcleb` and the last part `aapbdbdomjkkjkaonfhkkikfgjllcleb` is its unique ID.- 2. Configure the [OAuth Consent Screen](https://console.cloud.google.com/apis/credentials/consent). This information is shown to the user when giving consent to your app.- 3. Finally, add the client ID from step 1 in the [Google provider on the Supabase Dashboard](/dashboard/project/_/auth/providers), under _Client IDs_.+### Using the management API- Note that you do not have to configure the OAuth flow in the Supabase Dashboard to sign in with Google inside Chrome extensions.+Use the [PATCH `/v1/projects/{ref}/config/auth` Management API endpoint](/docs/reference/api/v1-update-auth-service-config) to configure the project's Auth settings programmatically. For configuring the Google provider send these options:- </TabPanel>-</Tabs>+```json+{+ "external_google_enabled": true,+ "external_google_client_id": "your-google-client-id",+ "external_google_secret": "your-google-client-secret"+}+```## Signing users in@@ -287,7 +276,7 @@ const { data, error } = await supabase.auth.signInWithOAuth({})```-### Google pre-built+### Google pre-built [#google-pre-built]Most web apps and websites can utilize Google's [personalized sign-in buttons](https://developers.google.com/identity/gsi/web/guides/personalized-button), [One Tap](https://developers.google.com/identity/gsi/web/guides/features) or [automatic sign-in](https://developers.google.com/identity/gsi/web/guides/automatic-sign-in-sign-out) for the best user experience.@@ -514,9 +503,7 @@ export default function () {</TabPanel>-<TabPanel id="flutter" label="Flutter">--### iOS and Android+<TabPanel id="flutter-mobile" label="Flutter (iOS and Android)">Google sign-in with Supabase is done through the [google_sign_in](https://pub.dev/packages/google_sign_in) package for iOS and Android.@@ -576,7 +563,18 @@ Future<void> _nativeGoogleSignIn() async {...```-### Web, macOS, Windows, and Linux+<div className="video-container">+ <iframe+ src="https://www.youtube-nocookie.com/embed/utMg6fVmX0U"+ frameBorder="1"+ allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"+ allowFullScreen+ ></iframe>+</div>++</TabPanel>++<TabPanel id="flutter-other" label="Flutter (web, macOS, Windows, Linux)">Google sign-in with Supabase on Web, macOS, Windows, and Linux is done through the [`signInWithOAuth`](docs/reference/dart/auth-signinwithoauth) method.@@ -808,12 +806,3 @@ chrome.identity.launchWebAuthFlow(</TabPanel></Tabs>--## Google consent screen----By default, the Google consent screen shows the root domain of the callback URL, where Google will send the authentication response. With Supabase Auth, it is your Supabase project's domain `(https://<your-project-ref>.supabase.co)`.--You can change this domain in the settings for your Google app. Go to Google App Platform, click on Branding, and then set your application home page, privacy policy, and terms of use. You can also add your logo.-Next, go to Audience and click publish. Google will need to verify the app, which usually takes around 24 hours.diff --git a/apps/docs/public/img/guides/auth-google/auth-google-consent-screen.png b/apps/docs/public/img/guides/auth-google/auth-google-consent-screen.pngdeleted file mode 100644index 76942f3b74d..00000000000Binary files a/apps/docs/public/img/guides/auth-google/auth-google-consent-screen.png and /dev/null differ