diff --git a/apps/docs/content/guides/auth/native-mobile-deep-linking.mdx b/apps/docs/content/guides/auth/native-mobile-deep-linking.mdx index 7017d7a779b..f80a71671a5 100644 --- a/apps/docs/content/guides/auth/native-mobile-deep-linking.mdx +++ b/apps/docs/content/guides/auth/native-mobile-deep-linking.mdx @@ -343,4 +343,58 @@ In certain auth scenarios you will need to handle linking back into your applica ``` + + ### Deep link config + + 1. Go to your [auth settings](https://supabase.com/dashboard/project/_/auth/url-configuration) page. + 2. Enter your app redirect URL in the `Additional Redirect URLs` field. This is the URL that the user gets redirected to after clicking a magic link. + + The redirect callback url should have the format `[YOUR_SCHEME]://[YOUR_HOSTNAME]`. Here, `io.supabase.user-management://login-callback` is just an example. You can choose whatever you would like for `YOUR_SCHEME` and `YOUR_HOSTNAME` as long as the scheme is unique across the user's device. For this reason, typically a reverse domain of your website is used. + + Now, edit the Android manifest to make sure the app opens when the user clicks on the magic link. + + ```xml + + + + + + + + + + + + + + + + + + ``` + + Check the [Android documentation](https://developer.android.com/training/app-links/deep-linking) for more information. + + Next, specify the scheme and host in the Supabase Client: + ```kotlin + install(Auth) { + host = "login-callback" + scheme = "io.supabase.user-management" + } + ``` + + Finally, call `Auth#handleDeeplinks` when the app opens: + + ```kotlin + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + supabase.handleDeeplinks(intent) + } + ``` + + The user will now be authenticated when your app receives a valid deeplink! + + diff --git a/apps/docs/content/guides/auth/social-login/auth-google.mdx b/apps/docs/content/guides/auth/social-login/auth-google.mdx index d7134a4ad6c..8360c023780 100644 --- a/apps/docs/content/guides/auth/social-login/auth-google.mdx +++ b/apps/docs/content/guides/auth/social-login/auth-google.mdx @@ -452,8 +452,7 @@ Before you can use Sign in with Google, you need to obtain a [Google Cloud Platf ## Using Google sign-in with Kotlin Multiplatform - When using [Compose Multiplatform](https://www.jetbrains.com/lp/compose-multiplatform/), you can use the [compose-auth](https://supabase.com/docs/reference/kotlin/installing) plugin. On Android it uses Google OneTap (or Credential Manager on Android 14+) automatically and on other platforms it uses `auth.signInWith(Google)`. - Alternatively, you can have a look at [Google One Tap](https://developers.google.com/identity/one-tap/android/overview), just login with the IdToken after you receive it. + When using [Compose Multiplatform](https://www.jetbrains.com/lp/compose-multiplatform/), you can use the [compose-auth](https://supabase.com/docs/reference/kotlin/installing) plugin. On Android it uses the Credential Manager automatically and on other platforms it uses `auth.signInWith(Google)`. **Initialize the Supabase Client** diff --git a/apps/docs/content/guides/realtime/guides/client-side-throttling.mdx b/apps/docs/content/guides/realtime/guides/client-side-throttling.mdx index dd673b92ccf..3921c2aceea 100644 --- a/apps/docs/content/guides/realtime/guides/client-side-throttling.mdx +++ b/apps/docs/content/guides/realtime/guides/client-side-throttling.mdx @@ -55,6 +55,20 @@ void main() async { final supabase = Supabase.instance.client; ``` + + + +```kotlin +val supabase = createSupabaseClient( + "https://.supabase.co", + "" +) { + install(Realtime) { + eventsPerSecond = 2 + } +} +``` + diff --git a/apps/docs/spec/supabase_kt_v2.yml b/apps/docs/spec/supabase_kt_v2.yml index a1ecb1479e1..c7880a741e0 100644 --- a/apps/docs/spec/supabase_kt_v2.yml +++ b/apps/docs/spec/supabase_kt_v2.yml @@ -29,11 +29,12 @@ functions: ### OAuth and OTP link verification [supabase-kt](https://github.com/supabase-community/supabase-kt) provides several platform implementations for OAuth and OTP link verification. \ - **On JVM**, it uses a HTTP Callback Server to receive the session data from a successful OAuth login. + **On Desktop platforms (JVM, MacOS\*, Linux)**, it uses a HTTP Callback Server to receive the session data from a successful OAuth login. The success page can be customized via `AuthConfig#httpCallbackConfig` + \* If no deeplinks are being used. *Note: OTP link verification such as sign ups are not supported on JVM. You may have to send a verification token rather than a url in your email. To send the token, rather than a redirect url, change `{{ .ConfirmationURL }}` in your sign up email to `{{ .Token }}`* - **On Android, iOS & MacOS**, OAuth and OTP verification use deeplinks. Refer to the guide below on how to setup deeplinks. Alternatively you can use Native Google Auth or a WebView for OAuth. Refer to the [demo](https://github.com/supabase-community/supabase-kt/tree/master/demos/android-login) to learn more. + **On Android, iOS & MacOS**, OAuth and OTP verification use deeplinks. Refer to the guide below on how to setup deeplinks. Alternatively you can use Native Google Auth. Refer to the [Supabase Auth documentation](/docs/guides/auth/social-login/auth-google?platform=android) to learn more. **On JS**, it uses the website origin as the callback url. Session importing gets handled automatically. **Windows, tvOS, watchOS & Linux** currently have no default implementation. Feel free to create a PR. @@ -61,6 +62,7 @@ functions: ``` 4. **Call platform specific function on startup** \ On Android: `supabase.handleDeeplinks(intent)` \ + If you don't want a separate activity, just call this function at the top of your `onCreate` function in your MainActivity. \ On iOS/MacOS: `supabase.handleDeeplinks(url)` Then you can log in using OAuth: @@ -2585,12 +2587,12 @@ functions: description: | - When the third-party provider successfully authenticates the user, the provider redirects the user to the URL specified in the `redirectUrl` parameter. This parameter defaults to the [`SITE_URL`](/docs/reference/auth/config#site_url). It does not redirect the user immediately after invoking this method. - See [redirect URLs and wildcards](/docs/guides/auth/overview#redirect-urls-and-wildcards) to add additional redirect URLs to your project. - - oAuthUrl() provides the URL which needs to be opened in a browser. + - getOAuthUrl() provides the URL which needs to be opened in a browser. - The redirectTo URL needs to be setup correctly in your project under Authentication -> URL Configuration -> Redirect URLs. - To see how you can use a custom in-app browser on Android, check our [demo](https://github.com/supabase-community/supabase-kt/tree/development/demos/android-login) on GitHub. code: | ```kotlin - val url = supabase.auth.oAuthUrl(Github, redirectUrl = "https://example.com") + val url = supabase.auth.getOAuthUrl(Github, redirectUrl = "https://example.com") ``` - id: sign-in-with-scopes name: Create a custom url with scopes @@ -2600,7 +2602,7 @@ functions: You may also need to specify the scopes in the provider's OAuth app settings, depending on the provider. The list of scopes will be documented by the third-party provider you are using and specifying scopes will enable you to use the OAuth provider token to call additional APIs supported by the third-party provider to get more information. code: | ```kotlin - val url = supabase.auth.oAuthUrl(Github, redirectUrl = "https://example.com") { + val url = supabase.auth.getOAuthUrl(Github, redirectUrl = "https://example.com") { scopes.add("email") } ``` @@ -2944,19 +2946,37 @@ functions: ```kotlin supabase.auth.sessionStatus.collect { when(it) { - is SessionStatus.Authenticated -> println(it.session.user) + is SessionStatus.Authenticated -> { + println("Received new authenticated session.") + when(it.source) { //Check the source of the session + SessionSource.External -> TODO() + is SessionSource.Refresh -> TODO() + is SessionSource.SignIn -> TODO() + is SessionSource.SignUp -> TODO() + SessionSource.Storage -> TODO() + SessionSource.Unknown -> TODO() + is SessionSource.UserChanged -> TODO() + is SessionSource.UserIdentitiesChanged -> TODO() + } + } SessionStatus.LoadingFromStorage -> println("Loading from storage") SessionStatus.NetworkError -> println("Network error") - SessionStatus.NotAuthenticated -> println("Not authenticated") + is SessionStatus.NotAuthenticated -> { + if(it.isSignOut) { + println("User signed out") + } else { + println("User not signed in") + } + } } } ``` description: | Types of statuses: - - `NotAuthenticated`, + - `NotAuthenticated(isSignOut)`, - `LoadingFromStorage`, - `NetworkError`, - - `Authenticated(session)` + - `Authenticated(session, source)` - id: reset-password-for-email title: 'Send a password reset request' notes: |