From 47aba5d31e6b31b0062dd8bf4e9dbf51d29ce44c Mon Sep 17 00:00:00 2001 From: Laura Beatris <48022589+LauraBeatris@users.noreply.github.com> Date: Wed, 15 Jan 2025 22:44:00 -0300 Subject: [PATCH] Update snippets --- docs/_partials/expo/oauth-custom-flow.mdx | 58 -------- docs/references/expo/use-oauth.mdx | 61 -------- docs/references/expo/use-sso.mdx | 164 +++++++++++++++++++--- 3 files changed, 145 insertions(+), 138 deletions(-) delete mode 100644 docs/_partials/expo/oauth-custom-flow.mdx delete mode 100644 docs/references/expo/use-oauth.mdx diff --git a/docs/_partials/expo/oauth-custom-flow.mdx b/docs/_partials/expo/oauth-custom-flow.mdx deleted file mode 100644 index 81f09bee6c..0000000000 --- a/docs/_partials/expo/oauth-custom-flow.mdx +++ /dev/null @@ -1,58 +0,0 @@ -The following example demonstrates how to create a custom OAuth sign-in flow for [Google accounts](/docs/authentication/social-connections/google). - -```tsx {{ filename: 'app/(auth)/sign-in.tsx', collapsible: true }} -import React from 'react' -import * as WebBrowser from 'expo-web-browser' -import { Text, View, Button } from 'react-native' -import { Link } from 'expo-router' -import { useOAuth } from '@clerk/clerk-expo' -import * as Linking from 'expo-linking' - -export const useWarmUpBrowser = () => { - React.useEffect(() => { - // Warm up the android browser to improve UX - // https://docs.expo.dev/guides/authentication/#improving-user-experience - void WebBrowser.warmUpAsync() - return () => { - void WebBrowser.coolDownAsync() - } - }, []) -} - -WebBrowser.maybeCompleteAuthSession() - -export default function Page() { - useWarmUpBrowser() - - const { startOAuthFlow } = useOAuth({ strategy: 'oauth_google' }) - - const onPress = React.useCallback(async () => { - try { - const { createdSessionId, signIn, signUp, setActive } = await startOAuthFlow({ - redirectUrl: Linking.createURL('/dashboard', { scheme: 'myapp' }), - }) - - // If sign in was successful, set the active session - if (createdSessionId) { - setActive!({ session: createdSessionId }) - } else { - // Use signIn or signUp returned from startOAuthFlow - // for next steps, such as MFA - } - } catch (err) { - // See https://clerk.com/docs/custom-flows/error-handling - // for more info on error handling - console.error(JSON.stringify(err, null, 2)) - } - }, []) - - return ( - - - Home - -