Skip to content

Commit

Permalink
fix intros to code examples
Browse files Browse the repository at this point in the history
  • Loading branch information
victoriaxyz committed Jan 16, 2025
1 parent dfb6e96 commit 1fd1a11
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions docs/references/expo/use-sso.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,16 @@ It accepts the following parameters (`StartSSOFlowParams`):
The [identifier](/docs/authentication/configuration/sign-up-sign-in-options#identifier) of the user. Required for `enterprise_sso` strategy.
</Properties>
## How to use `useSSO()`
## How to use `useSSO()` hook to create a custom SSO sign-in flow
<Tabs items={["With OAuth", "With SAML"]}>
<Tab>
The following example demonstrates how to create a custom SSO sign-in flow for [Google accounts](/docs/authentication/social-connections/google).
The `useSSO()` hook is used to create a new SSO flow with the `oauth_google` strategy. When the user presses the sign-in button, the `startSSOFlow()` method is called. If sign-in is successful, `createdSessionId` is used to set the active session. The `redirectUrl` parameter is used to specify the URL to redirect to after the SSO flow is complete.
If sign-in isn't successful, the `signIn` or `signUp` method returned from `startSSOFlow()` can be used to further authenticate the user.
```tsx {{ filename: 'app/(auth)/sign-in.tsx', collapsible: true }}
import React, { useCallback, useEffect } from 'react'
import * as WebBrowser from 'expo-web-browser'
Expand Down Expand Up @@ -111,7 +115,7 @@ It accepts the following parameters (`StartSSOFlowParams`):
// If sign in was successful, set the active session
setActive!({ session: createdSessionId })
} else {
// Use signIn or signUp returned from startOAuthFlow
// Use signIn or signUp returned from startSSOFlow
// for next steps, such as MFA
}
} catch (err) {
Expand All @@ -133,6 +137,10 @@ It accepts the following parameters (`StartSSOFlowParams`):
<Tab>
The following example demonstrates how to create a custom SSO sign-in flow with [SAML](docs/authentication/enterprise-connections/overview#saml).
The `useSSO()` hook is used to create a new SSO flow with the `enterprise_sso` strategy and the [`identifier`](/docs/authentication/configuration/sign-up-sign-in-options#identifier) parameter set to the user's email address. When the user presses the sign-in button, the `startSSOFlow()` method is called. If sign-in is successful, `createdSessionId` is used to set the active session. The `redirectUrl` parameter is used to specify the URL to redirect to after the SSO flow is complete.
If sign-in isn't successful, the `signIn` or `signUp` method returned from `startSSOFlow()` can be used to further authenticate the user.
```tsx {{ filename: 'app/(auth)/sign-in.tsx', collapsible: true }}
import React, { useCallback, useEffect } from 'react'
import * as WebBrowser from 'expo-web-browser'
Expand All @@ -158,7 +166,7 @@ It accepts the following parameters (`StartSSOFlowParams`):
export default function Page() {
useWarmUpBrowser()

const { startSSOFlow } = useSSO({ strategy: 'enterprise_sso' })
const { startSSOFlow } = useSSO({ strategy: 'enterprise_sso', identifier: 'email' })

const onPress = useCallback(async () => {
try {
Expand Down

0 comments on commit 1fd1a11

Please sign in to comment.