The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Add docs for SSO, Admin Api, MFA, and logging in using an IDToken
Jan Tennert1d47609f8e57
diff --git a/apps/docs/docs/ref/kotlin/installing.mdx b/apps/docs/docs/ref/kotlin/installing.mdxindex 223af69d2eb..d9352365f97 100644--- a/apps/docs/docs/ref/kotlin/installing.mdx+++ b/apps/docs/docs/ref/kotlin/installing.mdx@@ -6,7 +6,7 @@ custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supab----#### Add one or more modules to your project+### Add one or more modules to your project<RefSubLayout.EducationRow><RefSubLayout.Examples>@@ -103,7 +103,7 @@ custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supab</RefSubLayout.Examples></RefSubLayout.EducationRow>-#### Add Ktor Client Engine to each of your kotlin targets (required)+### Add Ktor Client Engine to each of your kotlin targets (required)<RefSubLayout.EducationRow><RefSubLayout.Examples>@@ -141,10 +141,47 @@ custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supab</TabPanel></Tabs>+ Multiplatform example:++ <Tabs+ size="small"+ type="underlined"+ defaultActiveId="kotlin">+ <TabPanel id="kotlin" label="build.gradle.kts">++ ```kotlin+ val commonMain by getting {+ dependencies {+ //supabase modules+ }+ }+ val jvmMain by getting {+ dependencies {+ implementation("io.ktor:ktor-client-cio:KTOR_VERSION")+ }+ }+ val androidMain by getting {+ dependsOn(jvmMain)+ }+ val jsMain by getting {+ dependencies {+ implementation("io.ktor:ktor-client-js:KTOR_VERSION")+ }+ }+ val iosMain by getting {+ dependencies {+ implementation("io.ktor:ktor-client-darwin:KTOR_VERSION")+ }+ }+ ```++ </TabPanel>+ </Tabs>+</RefSubLayout.Examples></RefSubLayout.EducationRow>-#### Add KotlinX Serialization (required for postgrest and realtime serialization)+### Add KotlinX Serialization (required for postgrest and realtime serialization)<RefSubLayout.EducationRow><RefSubLayout.Examples>@@ -211,5 +248,20 @@ custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supab</TabPanel></Tabs>+ Now you can create serializable classes in your project:+ ```kotlin+ @Serializable+ data class Message(+ val id: Int,+ val content: String,+ @SerialName("author_id")+ val authorId: String+ )+ ```+ And use them in your Supabase queries:+ ```kotlin+ val messages = client.postgrest["messages"].select().decodeList<Message>()+ ```+</RefSubLayout.Examples></RefSubLayout.EducationRow>\ No newline at end of filediff --git a/spec/supabase_kt_v0.yml b/spec/supabase_kt_v0.ymlindex cb95f22538a..abf906d915f 100644--- a/spec/supabase_kt_v0.yml+++ b/spec/supabase_kt_v0.yml@@ -71,7 +71,7 @@ functions:title: 'Fetch data: select()'notes: |Perform a SELECT query on the table or view.- - When calling a `decode` method, you have to provide a [serializable class]() as the type parameter.+ - When calling a `decode` method, you have to provide a [serializable class](/docs/reference/kotlin/installing#add-kotlinx-serialization-required-for-postgrest-and-realtime-serialization) as the type parameter.- You can provide a `Columns` object to select specific columns.- You can provide a [filter]() block to filter the resultsexamples:@@ -167,7 +167,7 @@ functions:title: 'Create data: insert()'$ref: '@supabase/postgrest-js."lib/PostgrestQueryBuilder".PostgrestQueryBuilder.insert'notes: |- - When calling an `insert` method, you have to provide a [serializable value]().+ - When calling an `insert` method, you have to provide a [serializable value](/docs/reference/kotlin/installing#add-kotlinx-serialization-required-for-postgrest-and-realtime-serialization).- By default, every time you run `insert()`, the client library will make a `select` to return the full record.This is convenient, but it can also cause problems if your policies are not configured to allow the `select` operation.If you are using Row Level Security and you are encountering problems, try setting the `returning` param to `Returning.MINIMAL`.@@ -204,7 +204,7 @@ functions:title: 'Modify data: update()'notes: |- `update()` should always be combined with a [filter] block to avoid updating all records.- - When calling a `decode` method, you have to provide a [serializable class]() as the type parameter.+ - When calling a `decode` method, you have to provide a [serializable class](/docs/reference/kotlin/installing#add-kotlinx-serialization-required-for-postgrest-and-realtime-serialization) as the type parameter.examples:- id: updating-your-dataname: Updating your data@@ -361,7 +361,7 @@ functions:That's a fancy way of saying that you can put some logic into your database then call it from anywhere.It's especially useful when the logic rarely changes - like password resets and updates.- - When calling specifying parameters, you have to provide a [serializable value]().+ - When calling specifying parameters, you have to provide a [serializable value](/docs/reference/kotlin/installing#add-kotlinx-serialization-required-for-postgrest-and-realtime-serialization).examples:- id: call-a-stored-procedurename: Call a stored procedure@@ -1385,8 +1385,8 @@ functions:code: |```kotlinclient.postgrest["issues"].select(columns = Columns.list("title")) {- Issue::tags overlaps listOf("is:closed", "severity:high")- //or+ Issue::tags overlaps listOf("is:closed", "severity:high")+ //oroverlaps("tags", listOf("is:closed", "severity:high"))}```@@ -1425,8 +1425,8 @@ functions:code: |```kotlinclient.postgrest["issues"].select(columns = Columns.list("title")) {- Issue::tags overlaps listOf("is:closed", "severity:high")- //or+ Issue::tags overlaps listOf("is:closed", "severity:high")+ //oroverlaps("tags", listOf("is:closed", "severity:high"))}```@@ -1478,8 +1478,8 @@ functions:name: Text searchcode: |```kotlin- client.postgrest["quotes"].select(columns = Columns.list("catchphrase")) {- textSearch(column = "catchphrase", query = "'fat' & 'cat'", config = "english", type = TextSearchType.YOUR_TYPE)+ client.postgrest["quotes"].select(columns = Columns.list("catchphrase")) {+ textSearch(column = "catchphrase", query = "'fat' & 'cat'", config = "english", type = TextSearchType.YOUR_TYPE)}```- id: basic-normalization@@ -1487,8 +1487,8 @@ functions:description: Uses PostgreSQL's `plainto_tsquery` function.code: |```kotlin- client.postgrest["quotes"].select(columns = Columns.list("catchphrase")) {- textSearch(column = "catchphrase", query = "'fat' & 'cat'", config = "english", type = TextSearchType.PLAINTO)+ client.postgrest["quotes"].select(columns = Columns.list("catchphrase")) {+ textSearch(column = "catchphrase", query = "'fat' & 'cat'", config = "english", type = TextSearchType.PLAINTO)}```- id: full-normalization@@ -1496,8 +1496,8 @@ functions:description: Uses PostgreSQL's `phraseto_tsquery` function.code: |```kotlin- client.postgrest["quotes"].select(columns = Columns.list("catchphrase")) {- textSearch(column = "catchphrase", query = "'fat' & 'cat'", config = "english", type = TextSearchType.PHRASETO)+ client.postgrest["quotes"].select(columns = Columns.list("catchphrase")) {+ textSearch(column = "catchphrase", query = "'fat' & 'cat'", config = "english", type = TextSearchType.PHRASETO)}```- id: web-search@@ -1514,8 +1514,8 @@ functions:code: |```kotlin- client.postgrest["quotes"].select(columns = Columns.list("catchphrase")) {- textSearch(column = "catchphrase", query = "'fat' & 'cat'", config = "english", type = TextSearchType.WEBSEARCH)+ client.postgrest["quotes"].select(columns = Columns.list("catchphrase")) {+ textSearch(column = "catchphrase", query = "'fat' & 'cat'", config = "english", type = TextSearchType.WEBSEARCH)}```@@ -1627,8 +1627,8 @@ functions:name: With `select()`code: |```kotlin- client.postgrest["countries"].select(columns = Columns.list("id", "name")) {- order(column = "id", order = Order.ASCENDING)+ client.postgrest["countries"].select(columns = Columns.list("id", "name")) {+ order(column = "id", order = Order.ASCENDING)}```data:@@ -1671,17 +1671,17 @@ functions:name: On a foreign tablecode: |```kotlin- client.postgrest["countries"].select(- columns = Columns.raw(- """- name,- cities (- name- )- """- )- ) {- order(column = "id", order = Order.ASCENDING, foreignTable = "cities")+ client.postgrest["countries"].select(+ columns = Columns.raw(+ """+ name,+ cities (+ name+ )+ """+ )+ ) {+ order(column = "id", order = Order.ASCENDING, foreignTable = "cities")}```data:@@ -1746,8 +1746,8 @@ functions:name: With `select()`code: |```kotlin- client.postgrest["countries"].select {- limit(count = 20)+ client.postgrest["countries"].select {+ limit(count = 20)}```data:@@ -1781,17 +1781,17 @@ functions:name: On a foreign tablecode: |```kotlin- client.postgrest["countries"].select(- columns = Columns.raw(- """- name,- cities (- name- )- """- )- ) {- limit(count = 20, foreignTable = "cities")+ client.postgrest["countries"].select(+ columns = Columns.raw(+ """+ name,+ cities (+ name+ )+ """+ )+ ) {+ limit(count = 20, foreignTable = "cities")}```data:@@ -1843,8 +1843,8 @@ functions:name: With `select()`code: |```kotlin- client.postgrest["countries"].select {- range(1L..5L)+ client.postgrest["countries"].select {+ range(1L..5L)}```data:@@ -1899,9 +1899,12 @@ functions:- If **Confirm email** is enabled, the return value is null, but the session is not.- If **Confirm email** is disabled, the return value is the user but the session is null.- When the user confirms their email address, they are redirected to the [`SITE_URL`](https://supabase.com/docs/reference/auth/config#site_url) by default. You can modify your `SITE_URL` or add additional redirect URLs in [your project](https://app.supabase.com/project/_/auth/url-configuration).+ - supabase-kt has default platform implementations: [deep links](https://developer.android.com/training/app-links/deep-linking) on Android, [url schemes](https://developer.apple.com/documentation/xcode/defining-a-custom-url-scheme-for-your-app) on IOS and the website on JS+ - To enable deeplinking/url scheme support on Android/IOS set the `host` and the `scheme` in the GoTrue Config and call `client.handleDeeplinks(intent)` (Android) and `client.handleDeeplinks(url)` (IOS) on startup+ - On Desktop, you can currently only verify a sign up through the token. To send the token, rather than a redirect url, you have to change `{{ .ConfirmationURL }}` in your sign up email to `{{ .Token }}`- If signUpWith() is called for an existing confirmed user:- - If **Confirm email** is enabled in [your project](https://app.supabase.com/project/_/auth/providers), an obfuscated/fake user object is returned.- - If **Confirm email** is disabled, the error message, `User already registered` is returned.+ - If **Confirm email** is enabled in [your project](https://app.supabase.com/project/_/auth/providers), an obfuscated/fake user object is returned.+ - If **Confirm email** is disabled, the error message, `User already registered` is returned.examples:- id: sign-upname: Sign up with email@@ -1974,6 +1977,22 @@ functions:password = "example-password"}```+ - id: sign-in-with-id-token+ name: Sign in with id token+ isSpotlight: false+ code: |+ ```kotlin+ client.gotrue.loginWith(IDToken) {+ idToken = "token"+ clientId = "oauth client id"+ provider = Google //Or Apple+ //optional:+ nonce = "nonce"+ data = buildJsonObject {+ //...+ }+ }+ ```- id: sign-in-with-otptitle: 'sendOtpTo()'$ref: '@supabase/gotrue-js.GoTrueClient.signInWithOtp'@@ -1985,6 +2004,9 @@ functions:- If you're using phone, you can configure whether you want the user to receive a OTP.- The magic link's destination URL is determined by the [`SITE_URL`](/docs/reference/auth/config#site_url).- See [redirect URLs and wildcards](/docs/guides/auth/overview#redirect-urls-and-wildcards) to add additional redirect URLs to your project.+ - supabase-kt has default platform implementations: [deep links](https://developer.android.com/training/app-links/deep-linking) on Android, [url schemes](https://developer.apple.com/documentation/xcode/defining-a-custom-url-scheme-for-your-app) on IOS and the website on JS+ - To enable deeplinking/url scheme support on Android/IOS set the `host` and the `scheme` in the GoTrue Config and call `client.handleDeeplinks(intent)` (Android) and `client.handleDeeplinks(url)` (IOS) on startup+ - On Desktop, you can currently only verify a sign up through the token. To send the token, rather than a redirect url, you have to change `{{ .ConfirmationURL }}` in your sign up email to `{{ .Token }}`- Magic links and OTPs share the same implementation. To send users a one-time code instead of a magic link, [modify the magic link email template](https://app.supabase.com/project/_/auth/templates) to include `{{ .Token }}` instead of `{{ .ConfirmationURL }}`.examples:- id: sign-in-with-email@@ -2058,6 +2080,42 @@ functions:scopes.add("email")}```+ - id: sign-in-with-sso+ title: 'signInWithSSO()'+ $ref: '@supabase/gotrue-js.GoTrueClient.signInWithSSO'+ notes: |+ - Before you can call this method you need to [establish a connection](/docs/guides/auth/sso/auth-sso-saml#managing-saml-20-connections) to an identity provider. Use the [CLI commands](/docs/reference/cli/supabase-sso) to do this.+ - If you've associated an email domain to the identity provider, you can use the `SSO.withDomain()` function in the `loginWith` method to start a sign-in flow.+ - In case you need to use a different way to start the authentication flow with an identity provider, you can use the `SSO.withProviderId` function. For example:+ - Mapping specific user email addresses with an identity provider.+ - Using different hints to identity the identity provider to be used by the user, like a company-specific page, IP address or other tracking information.+ - supabase-kt has default platform implementations: HTTP Callback Server on Desktop, [deep links](https://developer.android.com/training/app-links/deep-linking) on Android, [url schemes](https://developer.apple.com/documentation/xcode/defining-a-custom-url-scheme-for-your-app) on IOS and the website on JS+ - To enable deeplinking/url scheme support on Android/IOS set the `host` and the `scheme` in the GoTrue Config and call `client.handleDeeplinks(intent)` (Android) and `client.handleDeeplinks(url)` (IOS) on startup+ examples:+ - id: sign-in-with-domain+ name: Sign in with email domain+ isSpotlight: true+ code: |+ ```kotlin+ // You can extract the user's email domain and use it to trigger the+ // authentication flow with the correct identity provider.++ client.gotrue.loginWith(SSO.withDomain("company.com"))++ //the url was opened automatically, if you don't want that, provide a custom redirect url+ ```+ - id: sign-in-with-provider-uuid+ name: Sign in with provider UUID+ isSpotlight: true+ code: |+ ```kotlin+ // Useful when you need to map a user's sign in request according+ // to different rules that can't use email domains.++ client.gotrue.loginWith(SSO.withProvider("21648a9d-8d5a-4555-a9d1-d6375dc14e92"))++ //the url was opened automatically, if you don't want that, provide a custom redirect url+ ```- id: sign-outtitle: 'logout()'$ref: '@supabase/gotrue-js.GoTrueClient.signOut'@@ -2129,8 +2187,8 @@ functions:isSpotlight: falsecode: |```kotlin- val user = client.gotrue.modifyUser(Email) {- email = "[email protected]"+ val user = client.gotrue.modifyUser(Email) {+ email = "[email protected]"}```- id: update-the-password-for-an-authenticated-user@@ -2138,8 +2196,8 @@ functions:isSpotlight: falsecode: |```kotlin- val user = client.gotrue.modifyUser(Email) {- password = "secretPassword"+ val user = client.gotrue.modifyUser(Email) {+ password = "secretPassword"}```- id: update-the-users-metadata@@ -2147,8 +2205,8 @@ functions:isSpotlight: truecode: |```kotlin- val user = client.gotrue.modifyUser(Email, buildJsonObject {- put("name", "John")+ val user = client.gotrue.modifyUser(Email, buildJsonObject {+ put("name", "John")})```- id: set-session@@ -2199,15 +2257,461 @@ functions:isSpotlight: truecode: |```kotlin- client.gotrue.sessionStatus.collect {- when(it) {- is SessionStatus.Authenticated -> println(it.session.user)- SessionStatus.LoadingFromStorage -> println("Loading from storage")- SessionStatus.NetworkError -> println("Network error")- SessionStatus.NotAuthenticated -> println("Not authenticated")+ client.gotrue.sessionStatus.collect {+ when(it) {+ is SessionStatus.Authenticated -> println(it.session.user)+ SessionStatus.LoadingFromStorage -> println("Loading from storage")+ SessionStatus.NetworkError -> println("Network error")+ SessionStatus.NotAuthenticated -> println("Not authenticated")+ }+ }+ ```+ - id: reset-password-for-email+ title: 'Send a password reset request'+ notes: |+ - The password reset flow consist of 2 broad steps: (i) Allow the user to login via the password reset link; (ii) Update the user's password.+ - The `sendRecoveryEmail()` only sends a password reset link to the user's email.+ To update the user's password, see [`modifyUser()`](/docs/reference/kotlin/auth-updateuser).+ - When the user clicks the reset link in the email they are redirected back to your application.+ You can configure the URL that the user is redirected to with the `redirectUrl` parameter.+ See [redirect URLs and wildcards](/docs/guides/auth#redirect-urls-and-wildcards) to add additional redirect URLs to your project.+ - After the user has been redirected successfully, prompt them for a new password and call `modifyUser()`:+ ```kotlin+ client.gotrue.modifyUser(Email) {+ password = "1234567"+ }+ ```+ examples:+ - id: send-password-reset-email+ name: Send password reset email+ isSpotlight: true+ code: |+ ```kotlin+ client.gotrue.sendRecoveryEmail(email = "[email protected]")+ ```+ - id: mfa-enroll+ title: 'Enroll a factor'+ $ref: '@supabase/gotrue-js.GoTrueMFAApi.enroll'+ notes: |+ - Currently, `totp` is the only supported `factorType`. The returned `id` should be used to create a challenge.+ - To create a challenge, see [`mfa.createChallenge()`](/docs/reference/kotlin/auth-mfa-challenge).+ - To verify a challenge, see [`mfa.verifyChallenge()`](/docs/reference/kotlin/auth-mfa-verify).+ - To create and verify a challenge in a single step, see [`mfa.createChallengeAndVerify()`](/docs/reference/kotlin/auth-mfa-challengeandverify).+ examples:+ - id: enroll-totp-factor+ name: Enroll a time-based, one-time password (TOTP) factor+ isSpotlight: true+ code: |+ ```kotlin+ val factor = client.gotrue.mfa.enroll(factorType = FactorType.TOTP)++ // Use the id to create a challenge.+ // The challenge can be verified by entering the code generated from the authenticator app.+ // The code will be generated upon scanning the qr_code or entering the secret into the authenticator app.+ val (id, type, qrCode) = factor.data //qrCode is a svg as a string+ val (factorId, factorType, _) = factor+ ```+ - id: get-local-verified-factors+ name: Check the local user for verified factors+ isSpotlight: true+ code: |+ ```kotlin+ val verifiedFactors = client.gotrue.mfa.verifiedFactors+ ```+ - id: retrieve-verified-factors+ name: Retrieve verified factors+ isSpotlight: true+ code: |+ ```kotlin+ val verifiedFactors = client.gotrue.mfa.retrieveFactorsForCurrentUser()+ ```+ - id: mfa-challenge+ title: 'mfa.challenge()'+ $ref: '@supabase/gotrue-js.GoTrueMFAApi.challenge'+ notes: |+ - An [enrolled factor](/docs/reference/kotlin/auth-mfa-enroll) is required before creating a challenge.+ - To verify a challenge, see [`mfa.verifyChallenge()`](/docs/reference/kotlin/auth-mfa-verify).+ examples:+ - id: create-mfa-challenge+ name: Create a challenge for a factor+ isSpotlight: true+ code: |+ ```kotlin+ val challenge = client.gotrue.mfa.createChallenge(factorId = "34e770dd-9ff9-416c-87fa-43b31d7ef225")+ ```+ - id: mfa-verify+ title: 'mfa.verify()'+ $ref: '@supabase/gotrue-js.GoTrueMFAApi.verify'+ notes: |+ - To verify a challenge, please [create a challenge](/docs/reference/kotlin/auth-mfa-challenge) first.+ examples:+ - id: verify-challenge+ name: Verify a challenge for a factor+ isSpotlight: true+ code: |+ ```kotlin+ client.gotrue.mfa.verifyChallenge(+ factorId = "34e770dd-9ff9-416c-87fa-43b31d7ef225",+ challengeId = "4034ae6f-a8ce-4fb5-8ee5-69a5863a7c15",+ code = "123456",+ saveSession = true // this is set to true by default, but you can set it to false if you want to handle the session yourself+ )+ ```+ - id: mfa-challenge-and-verify+ title: 'mfa.challengeAndVerify()'+ $ref: '@supabase/gotrue-js.GoTrueMFAApi.challengeAndVerify'+ notes: |+ - An [enrolled factor](/docs/reference/kotlin/auth-mfa-enroll) is required before invoking `createChallengeAndVerify()`.+ - Executes [`mfa.createChallenge()`](/docs/reference/kotlin/auth-mfa-challenge) and [`mfa.verifyChallenge()`](/docs/reference/kotlin/auth-mfa-verify) in a single step.+ examples:+ - id: challenge-and-verify+ name: Create and verify a challenge for a factor+ isSpotlight: true+ code: |+ ```kotlin+ client.gotrue.mfa.createChallengeAndVerify(+ factorId = "34e770dd-9ff9-416c-87fa-43b31d7ef225",+ code = "123456",+ saveSession = true // this is set to true by default, but you can set it to false if you want to handle the session yourself+ )+ ```+ - id: mfa-unenroll+ title: 'mfa.unenroll()'+ $ref: '@supabase/gotrue-js.GoTrueMFAApi.unenroll'+ examples:+ - id: unenroll-a-factor+ name: Unenroll a factor+ isSpotlight: true+ code: |+ ```kotlin+ client.gotrue.mfa.unenroll(factorId = "34e770dd-9ff9-416c-87fa-43b31d7ef225")+ ```+ - id: mfa-get-authenticator-assurance-level+ title: 'mfa.getAuthenticatorAssuranceLevel()'+ $ref: '@supabase/gotrue-js.GoTrueMFAApi.getAuthenticatorAssuranceLevel'+ notes: |+ - Authenticator Assurance Level (AAL) is the measure of the strength of an authentication mechanism.+ - In Supabase, having an AAL of `aal1` refers to having the 1st factor of authentication such as an email and password or OAuth sign-in while `aal2` refers to the 2nd factor of authentication such as a time-based, one-time-password (TOTP).+ - If the user has a verified factor, the `next` field will return `AuthenticatorAssuranceLevel.AAL2`, else, it will return `AuthenticatorAssuranceLevel.AAL1`.+ examples:+ - id: get-aal+ name: Get the AAL details of the current session+ isSpotlight: true+ code: |+ ```kotlin+ val (current, next) = client.gotrue.mfa.getAuthenticatorAssuranceLevel()+ ```+ - id: aal-enabled+ name: Check whether the user has atleast one verified factor+ isSpotlight: true+ code: |+ ```kotlin+ val enabled = client.gotrue.mfa.isMfaEnabled+ //flow variant, automatically emitting new values on session changes+ val enabledFlow = client.gotrue.mfa.isMfaEnabledFlow+ ```+ - id: aal-enabled-for-current-session+ name: Check whether the user is logged in using AAL2+ isSpotlight: true+ code: |+ ```kotlin+ val loggedInUsingMfa = client.gotrue.mfa.loggedInUsingMfa+ //flow variant, automatically emitting new values on session changes+ val loggedInUsingMfaFlow = client.gotrue.mfa.loggedInUsingMfaFlow+ ```+ - id: admin-api+ title: 'Overview'+ notes: |+ - Any method under the `client.gotrue.admin` namespace requires a `service_role` key.+ - These methods are considered admin methods and should be called on a trusted server. Never expose your `service_role` key in the browser.+ examples:+ - id: create-auth-admin-client+ name: Create server-side auth client+ isSpotlight: true+ code: |+ ```kotlin+ val client = createSupabaseClient(+ supabaseUrl = "https://id.supabase.co",+ supabaseKey = "service_role"+ ) {+ install(GoTrue) {+ autoLoadFromStorage = false+ alwaysAutoRefresh = false+ }+ }++ // Access auth admin api+ val adminGoTrueClient = client.gotrue.admin+ ```++ - id: get-user-by-id+ title: 'getUserById()'+ $ref: '@supabase/gotrue-js.GoTrueAdminApi.getUserById'+ notes: |+ - Fetches the user object from the database based on the user's id.+ - The `retrieveUserById()` method requires the user's id which maps to the `auth.users.id` column.+ examples:+ - id: fetch-the-user-object-using-the-access-token-jwt+ name: Fetch the user object using the access_token jwt+ isSpotlight: true+ code: |+ ```kotlin+ val user = client.gotrue.admin.retrieveUserById(uid = "f2a0b0a0-6b1a-4b7a-8f1a-4b7a6b1a8f1a")+ ```++ - id: list-users+ title: 'listUsers()'+ $ref: '@supabase/gotrue-js.GoTrueAdminApi.listUsers'+ notes: |+ - Defaults to return 50 users per page.+ examples:+ - id: get-a-full-list-of-users+ name: Get a page of users+ isSpotlight: true+ code: |+ ```kotlin+ val users = client.gotrue.admin.retrieveUsers()+ ```+ - id: get-paginated-list-of-users+ name: Paginated list of users+ isSpotlight: false+ code: |+ ```kotlin+ val users = client.gotrue.admin.retrieveUsers(+ page = 1,+ perPage = 100+ )+ ```+ - id: create-user+ title: 'createUser()'+ $ref: '@supabase/gotrue-js.GoTrueAdminApi.createUser'+ notes: |+ - To confirm the user's email address or phone number, set `autoConfirm` to true. Both arguments default to false.+ examples:+ - id: create-a-new-user-with-email-custom-user-metadata+ name: Create user with email+ isSpotlight: true+ code: |+ ```kotlin+ val userWithEmail = client.gotrue.admin.createUserWithEmail {+ email = "[email protected]"+ password = "secretpassword"+ userMetadata {+ put("name", "John")+ }+ }+ ```+ - id: create-a-new-user-with-phone-custom-user-metadata+ name: Create user with phone+ isSpotlight: true+ code: |+ ```kotlin+ val userWithPhone = client.gotrue.admin.createUserWithPhone {+ phoneNumber = "+49123456789"+ password = "secretpassword"+ userMetadata {+ put("name", "John")+ }+ }+ ```+ - id: auto-confirm-the-users-email+ name: Auto-confirm the user's email+ code: |+ ```kotlin+ val userWithEmail = client.gotrue.admin.createUserWithEmail {+ email = "[email protected]"+ password = "secretpassword"+ autoConfirm = true+ }+ ```+ - id: auto-confirm-the-users-phone-number+ name: Auto-confirm the user's phone number+ code: |+ ```kotlin+ val userWithPhone = client.gotrue.admin.createUserWithPhone {+ phoneNumber = "+49123456789"+ password = "secretpassword"+ autoConfirm = true+ }+ ```+ - id: delete-user+ title: 'deleteUser()'+ $ref: '@supabase/gotrue-js.GoTrueAdminApi.deleteUser'+ notes: |+ - The `deleteUser()` method requires the user's ID, which maps to the `auth.users.id` column.+ examples:+ - id: removes-a-user+ name: Removes a user+ isSpotlight: true+ code: |+ ```kotlin+ client.gotrue.admin.deleteUser(uid = "uid")+ ```++ - id: invite-user-by-email+ title: 'inviteUserByEmail()'+ $ref: '@supabase/gotrue-js.GoTrueAdminApi.inviteUserByEmail'+ notes: |+ - Sends an invite link to the user's email address.+ examples:+ - id: invite-a-user+ name: Invite a user+ isSpotlight: true+ code: |+ ```kotlin+ client.gotrue.admin.inviteUserByEmail(+ email = "[email protected]",+ //optional:+ redirectTo = "https://example.com/redirect",+ data = buildJsonObject {+ put("custom", "value")}+ )+ ```++ - id: generate-link+ title: 'generateLink()'+ $ref: '@supabase/gotrue-js.GoTrueAdminApi.generateLink'+ examples:+ - id: generate-a-signup-link+ name: Generate a signup link+ isSpotlight: true+ code: |+ ```kotlin+ val (url, user) = client.gotrue.admin.generateLinkFor(LinkType.Signup) {+ email = "[email protected]"+ password = "secretpassword"+ }+ ```+ - id: generate-an-invite-link+ name: Generate an invite link+ isSpotlight: false+ code: |+ ```kotlin+ val (url, user) = client.gotrue.admin.generateLinkFor(LinkType.Invite) {+ email = "[email protected]"+ }+ ```+ - id: generate-a-magic-link+ name: Generate a magic link+ isSpotlight: false+ code: |+ ```kotlin+ val (url, user) = client.gotrue.admin.generateLinkFor(LinkType.MagicLink) {+ email = "[email protected]"+ }+ ```+ - id: generate-a-recovery-link+ name: Generate a recovery link+ isSpotlight: false+ code: |+ ```kotlin+ val (url, user) = client.gotrue.admin.generateLinkFor(LinkType.Recovery) {+ email = "[email protected]"+ }+ ```+ - id: generate-links-to-change-current-email-address+ name: Generate links to change current email address+ isSpotlight: false+ code: |+ ```kotlin+ // generate an email change link to be sent to the current email address+ val (url, user) = client.gotrue.admin.generateLinkFor(LinkType.EmailChangeCurrent) {+ email = "[email protected]"+ newEmail = "[email protected]"+ }++ // generate an email change link to be sent to the new email address+ val (url, user) = client.gotrue.admin.generateLinkFor(LinkType.EmailChangeNew) {+ email = "[email protected]"+ newEmail = "[email protected]"+ }+ ```++ - id: update-user-by-id+ title: 'updateUserById()'+ $ref: '@supabase/gotrue-js.GoTrueAdminApi.updateUserById'+ examples:+ - id: updates-a-users-email+ name: Updates a user's email+ isSpotlight: false+ code: |+ ```kotlin+ client.gotrue.admin.updateUserById(uid = "id") {+ email = "[email protected]"+ }+ ```+ - id: updates-a-users-password+ name: Updates a user's password+ isSpotlight: false+ code: |+ ```js+ client.gotrue.admin.updateUserById(uid = "id") {+ password = "password"+ }+ ```+ - id: updates-a-users-metadata+ name: Updates a user's metadata+ isSpotlight: true+ code: |+ ```kotlin+ client.gotrue.admin.updateUserById(uid = "id") {+ userMetadata = buildJsonObject {+ put("key", "value")+ }+ }+ ```+ - id: updates-a-users-app-metadata+ name: Updates a user's app_metadata+ isSpotlight: false+ code: |+ ```kotlin+ client.gotrue.admin.updateUserById(uid = "id") {+ appMetadata = buildJsonObject {+ put("key", "value")+ }+ }+ ```+ - id: confirms-a-users-email-address+ name: Confirms a user's email address+ isSpotlight: false+ code: |+ ```kotlin+ client.gotrue.admin.updateUserById(uid = "id") {+ emailConfirm = true}```+ - id: confirms-a-users-phone-number+ name: Confirms a user's phone number+ isSpotlight: false+ code: |+ ```kotlin+ client.gotrue.admin.updateUserById(uid = "id") {+ phoneConfirm = true+ }+ ```+ - id: mfa-list-factors+ title: 'mfa.listFactors()'+ $ref: '@supabase/gotrue-js.GoTrueAdminMFAApi.listFactors'+ examples:+ - id: list-factors+ name: List all factors for a user+ isSpotlight: true+ code: |+ ```kotlin+ const factors = client.gotrue.admin.retrieveFactors(uid = "id")+ ```+ - id: mfa-delete-factor+ title: 'mfa.deleteFactor()'+ $ref: '@supabase/gotrue-js.GoTrueAdminMFAApi.deleteFactor'+ examples:+ - id: delete-factor+ name: Delete a factor for a user+ isSpotlight: true+ code: |+ ```kotlin+ client.gotrue.admin.deleteFactor(uid = "id", factorId = "factor_id")+ ```- id: invoketitle: 'invoke()'description: |@@ -2261,107 +2765,107 @@ functions:name: Listen to broadcastscode: |```kotlin- @Serializable+ @Serializabledata class Message(val content: String, val sender: String)- val channel = client.realtime.createChannel("channelId") {- //optional config- }-- val broadcastFlow = channel.broadcastFlow<Message>(event = "message")-- //in a new coroutine (or use Flow.onEach().launchIn(scope)):- broadcastFlow.collect { //it: Message- println(it)- }-- channel.join(blockUntilJoined = true)-+ val channel = client.realtime.createChannel("channelId") {+ //optional config+ }++ val broadcastFlow = channel.broadcastFlow<Message>(event = "message")++ //in a new coroutine (or use Flow.onEach().launchIn(scope)):+ broadcastFlow.collect { //it: Message+ println(it)+ }++ channel.join(blockUntilJoined = true)+channel.broadcast(event = "message", Message("I joined!", "John"))```- id: listen-to-presence-updatesname: Listen to presence updatescode: |```kotlin- @Serializable+ @Serializabledata class PresenceState(val username: String)- val connectedUsers = mutableSetOf<PresenceState>()- val channel = client.realtime.createChannel("channelId") {- //optional config- }-- val presenceChangeFlow = channel.presenceChangeFlow()+ val connectedUsers = mutableSetOf<PresenceState>()+ val channel = client.realtime.createChannel("channelId") {+ //optional config+ }++ val presenceChangeFlow = channel.presenceChangeFlow()++ //in a new coroutine (or use Flow.onEach().launchIn(scope)):+ presenceChangeFlow.collect {+ connectedUsers += it.decodeJoinsAs<PresenceState>()+ connectedUsers -= it.decodeLeavesAs<PresenceState>()+ }- //in a new coroutine (or use Flow.onEach().launchIn(scope)):- presenceChangeFlow.collect {- connectedUsers += it.decodeJoinsAs<PresenceState>()- connectedUsers -= it.decodeLeavesAs<PresenceState>()- }-- channel.join(blockUntilJoined = true)- //send own state+ channel.join(blockUntilJoined = true)+ //send own statechannel.track(PresenceState(username = "John"))- id: listen-to-all-database-changesname: Listen to all database changescode: |```kotlin- val channel = client.realtime.createChannel("channelId") {- //optional config- }- val changeFlow = channel.postgresChangeFlow<PostgresAction>(schema = "public")-- //in a new coroutine (or use Flow.onEach().launchIn(scope)):- changeFlow.collect {- when(it) {- is PostgresAction.Delete -> println("Deleted: ${it.oldRecord}")- is PostgresAction.Insert -> println("Inserted: ${it.record}")- is PostgresAction.Select -> println("Selected: ${it.record}")- is PostgresAction.Update -> println("Updated: ${it.oldRecord} with ${it.record}")- }- }-+ val channel = client.realtime.createChannel("channelId") {+ //optional config+ }+ val changeFlow = channel.postgresChangeFlow<PostgresAction>(schema = "public")++ //in a new coroutine (or use Flow.onEach().launchIn(scope)):+ changeFlow.collect {+ when(it) {+ is PostgresAction.Delete -> println("Deleted: ${it.oldRecord}")+ is PostgresAction.Insert -> println("Inserted: ${it.record}")+ is PostgresAction.Select -> println("Selected: ${it.record}")+ is PostgresAction.Update -> println("Updated: ${it.oldRecord} with ${it.record}")+ }+ }+channel.join()```- id: listen-to-a-specific-tablename: Listen to a specific tablecode: |```kotlin- val channel = client.realtime.createChannel("channelId") {- //optional config- }- val changeFlow = channel.postgresChangeFlow<PostgresAction>(schema = "public") {- table = "users"- }-- //in a new coroutine (or use Flow.onEach().launchIn(scope)):- changeFlow.collect {- when(it) {- is PostgresAction.Delete -> println("Deleted: ${it.oldRecord}")- is PostgresAction.Insert -> println("Inserted: ${it.record}")- is PostgresAction.Select -> println("Selected: ${it.record}")- is PostgresAction.Update -> println("Updated: ${it.oldRecord} with ${it.record}")- }- }-+ val channel = client.realtime.createChannel("channelId") {+ //optional config+ }+ val changeFlow = channel.postgresChangeFlow<PostgresAction>(schema = "public") {+ table = "users"+ }++ //in a new coroutine (or use Flow.onEach().launchIn(scope)):+ changeFlow.collect {+ when(it) {+ is PostgresAction.Delete -> println("Deleted: ${it.oldRecord}")+ is PostgresAction.Insert -> println("Inserted: ${it.record}")+ is PostgresAction.Select -> println("Selected: ${it.record}")+ is PostgresAction.Update -> println("Updated: ${it.oldRecord} with ${it.record}")+ }+ }+channel.join()```- id: listen-to-insertsname: Listen to insertscode: |```kotlin- val channel = client.realtime.createChannel("channelId") {- //optional config- }- val changeFlow = channel.postgresChangeFlow<PostgresAction.Insert>(schema = "public") {- table = "users"- }-- //in a new coroutine (or use Flow.onEach().launchIn(scope)):- changeFlow.collect {- println(it.record)- }-+ val channel = client.realtime.createChannel("channelId") {+ //optional config+ }+ val changeFlow = channel.postgresChangeFlow<PostgresAction.Insert>(schema = "public") {+ table = "users"+ }++ //in a new coroutine (or use Flow.onEach().launchIn(scope)):+ changeFlow.collect {+ println(it.record)+ }+channel.join()```- id: listen-to-updates@@ -2375,19 +2879,19 @@ functions:```code: |```kotlin- val channel = client.realtime.createChannel("channelId") {- //optional config- }- val changeFlow = channel.postgresChangeFlow<PostgresAction.Update>(schema = "public") {- table = "users"- }-- //in a new coroutine (or use Flow.onEach().launchIn(scope)):- changeFlow.collect {- println(it.record)- println(it.oldRecord)- }-+ val channel = client.realtime.createChannel("channelId") {+ //optional config+ }+ val changeFlow = channel.postgresChangeFlow<PostgresAction.Update>(schema = "public") {+ table = "users"+ }++ //in a new coroutine (or use Flow.onEach().launchIn(scope)):+ changeFlow.collect {+ println(it.record)+ println(it.oldRecord)+ }+channel.join()```- id: listen-to-deletes@@ -2401,18 +2905,18 @@ functions:```code: |```kotlin- val channel = client.realtime.createChannel("channelId") {- //optional config- }- val changeFlow = channel.postgresChangeFlow<PostgresAction.Delete>(schema = "public") {- table = "users"- }-- //in a new coroutine (or use Flow.onEach().launchIn(scope)):- changeFlow.collect {- println(it.oldRecord)- }-+ val channel = client.realtime.createChannel("channelId") {+ //optional config+ }+ val changeFlow = channel.postgresChangeFlow<PostgresAction.Delete>(schema = "public") {+ table = "users"+ }++ //in a new coroutine (or use Flow.onEach().launchIn(scope)):+ changeFlow.collect {+ println(it.oldRecord)+ }+channel.join()```- id: listening-to-row-level-changes@@ -2420,19 +2924,19 @@ functions:description: You can listen to individual rows using the format `{table}:{col}=eq.{val}` - where `{col}` is the column name, and `{val}` is the value which you want to match.code: |```kotlin- val channel = client.realtime.createChannel("channelId") {- //optional config- }- val changeFlow = channel.postgresChangeFlow<PostgresAction.Delete>(schema = "public") {- table = "users"- filter = "id.eq.1"- }-- //in a new coroutine:- changeFlow.collect {- println(it.oldRecord)- }-+ val channel = client.realtime.createChannel("channelId") {+ //optional config+ }+ val changeFlow = channel.postgresChangeFlow<PostgresAction.Delete>(schema = "public") {+ table = "users"+ filter = "id.eq.1"+ }++ //in a new coroutine:+ changeFlow.collect {+ println(it.oldRecord)+ }+channel.join()```@@ -2449,10 +2953,10 @@ functions:isSpotlight: truecode: |```kotlin- val channel = client.realtime.createChannel("channelId") {- //optional config- }- //...+ val channel = client.realtime.createChannel("channelId") {+ //optional config+ }+ //...client.realtime.removeChannel(channel)```- id: unsubscribe-channel@@ -2460,11 +2964,11 @@ functions:isSpotlight: truecode: |```kotlin- val channel = client.realtime.createChannel("channelId") {- //optional config- }- //...- channel.leave()+ val channel = client.realtime.createChannel("channelId") {+ //optional config+ }+ //...+ channel.leave()```- id: list-bucketstitle: listBuckets()@@ -2514,9 +3018,9 @@ functions:isSpotlight: truecode: |```kotlin- client.storage.createBucket(name = "icons", id = "icons") {- public = true- fileSizeLimit = 5.megabytes+ client.storage.createBucket(name = "icons", id = "icons") {+ public = true+ fileSizeLimit = 5.megabytes}```@@ -2567,9 +3071,9 @@ functions:isSpotlight: truecode: |```kotlin- val bucket = client.storage["avatars"]- bucket.upload("myIcon.png", byteArray, upsert = false)- //on JVM you can use java.io.File+ val bucket = client.storage["avatars"]+ bucket.upload("myIcon.png", byteArray, upsert = false)+ //on JVM you can use java.io.Filebucket.upload("myIcon.png", file, upsert = false)```- id: upload-file-with-progress@@ -2577,12 +3081,12 @@ functions:isSpotlight: truecode: |```kotlin- val bucket = client.storage["avatars"]- bucket.uploadAsFlow("test.png", byteArrayOf()).collect {- when(it) {- is UploadStatus.Progress -> println("Progress: ${it.totalBytesSend.toFloat() / it.contentLength * 100}%")- is UploadStatus.Success -> println("Success")- }+ val bucket = client.storage["avatars"]+ bucket.uploadAsFlow("test.png", byteArrayOf()).collect {+ when(it) {+ is UploadStatus.Progress -> println("Progress: ${it.totalBytesSend.toFloat() / it.contentLength * 100}%")+ is UploadStatus.Success -> println("Success")+ }}```- id: create-resumable-upload@@ -2590,22 +3094,22 @@ functions:isSpotlight: truecode: |```kotlin- val bucket = client.storage["avatars"]- val upload = bucket.resumable.createOrContinueUpload("icon.png", File("icon.png"))- //start or continue uploading- upload.startOrResumeUploading()-- //pause uploading- upload.pause()-- //cancel uploading- upload.cancel()-- //listen to upload status- upload.stateFlow.collect {- println("Progress: ${it.progress * 100}%")- println("Paused: ${it.paused}")- println("Is done: ${it.isDone}")+ val bucket = client.storage["avatars"]+ val upload = bucket.resumable.createOrContinueUpload("icon.png", File("icon.png"))+ //start or continue uploading+ upload.startOrResumeUploading()++ //pause uploading+ upload.pause()++ //cancel uploading+ upload.cancel()++ //listen to upload status+ upload.stateFlow.collect {+ println("Progress: ${it.progress * 100}%")+ println("Paused: ${it.paused}")+ println("Is done: ${it.isDone}")}```- id: continue-previous-upload@@ -2613,9 +3117,9 @@ functions:isSpotlight: truecode: |```kotlin- val bucket = client.storage["avatars"]- bucket.resumable.continuePreviousFileUploads().map { it.await() }.forEach { upload ->- upload.startOrResumeUploading()+ val bucket = client.storage["avatars"]+ bucket.resumable.continuePreviousFileUploads().map { it.await() }.forEach { upload ->+ upload.startOrResumeUploading()}```@@ -2633,9 +3137,9 @@ functions:isSpotlight: truecode: |```kotlin- val bucket = client.storage["avatars"]- bucket.update("myIcon.png", byteArray, upsert = false)- //on JVM you can use java.io.File+ val bucket = client.storage["avatars"]+ bucket.update("myIcon.png", byteArray, upsert = false)+ //on JVM you can use java.io.Filebucket.update("myIcon.png", file, upsert = false)```@@ -2653,7 +3157,7 @@ functions:isSpotlight: truecode: |```kotlin- val bucket = client.storage["avatars"]+ val bucket = client.storage["avatars"]bucket.move("icon1.png", "icon2.png")```@@ -2671,18 +3175,18 @@ functions:isSpotlight: truecode: |```kotlin- val bucket = client.storage["avatars"]+ val bucket = client.storage["avatars"]val url = bucket.createSignedUrl(path = "icon.png", expiresIn = 3.minutes)```- id: create-signed-url-with-transformationname: Create Signed URL with transformationcode: |```kotlin- val bucket = client.storage["avatars"]- val url = bucket.createSignedUrl(path = "icon.png", expiresIn = 3.minutes) {- size(100, 100)- fill()- quality = 80+ val bucket = client.storage["avatars"]+ val url = bucket.createSignedUrl(path = "icon.png", expiresIn = 3.minutes) {+ size(100, 100)+ fill()+ quality = 80}```- id: from-download@@ -2699,7 +3203,7 @@ functions:isSpotlight: truecode: |```kotlin- val bucket = client.storage["avatars"]+ val bucket = client.storage["avatars"]val bytes = bucket.downloadAuthenticated("test.png")//or on JVM:bucket.downloadAuthenticatedTo("test.png", File("test.png"))@@ -2709,7 +3213,7 @@ functions:isSpotlight: truecode: |```kotlin- val bucket = client.storage["avatars"]+ val bucket = client.storage["avatars"]val bytes = bucket.downloadPublic("test.png")//or on JVM:bucket.downloadPublicTo("test.png", File("test.png"))@@ -2718,24 +3222,24 @@ functions:name: Download file with transformationcode: |```kotlin- val bucket = client.storage["avatars"]- val bytes = bucket.downloadPublic("test.png") {- size(100, 100)- fill()- quality = 100+ val bucket = client.storage["avatars"]+ val bytes = bucket.downloadPublic("test.png") {+ size(100, 100)+ fill()+ quality = 100}```- id: download-with-progressname: Download file with progresscode: |```kotlin- val bucket = client.storage["avatars"]- bucket.downloadAuthenticatedAsFlow("icon.png").collect {- when(it) {- is DownloadStatus.ByteData -> println("Downloaded ${it.data.size} bytes")- is DownloadStatus.Progress -> println("Downloaded ${it.totalBytesReceived.toFloat() / it.contentLength * 100}%")- DownloadStatus.Success -> println("Downloaded successfully")- }+ val bucket = client.storage["avatars"]+ bucket.downloadAuthenticatedAsFlow("icon.png").collect {+ when(it) {+ is DownloadStatus.ByteData -> println("Downloaded ${it.data.size} bytes")+ is DownloadStatus.Progress -> println("Downloaded ${it.totalBytesReceived.toFloat() / it.contentLength * 100}%")+ DownloadStatus.Success -> println("Downloaded successfully")+ }}```- id: from-remove@@ -2752,7 +3256,7 @@ functions:isSpotlight: truecode: |```kotlin- val bucket = client.storage["avatars"]+ val bucket = client.storage["avatars"]bucket.delete("test.png", "test2.png")```@@ -2770,6 +3274,6 @@ functions:isSpotlight: truecode: |```kotlin- val bucket = client.storage["avatars"]+ val bucket = client.storage["avatars"]val files = bucket.list()```