From a099a50ee1ef7d1ee05ddcb6610056a2535be351 Mon Sep 17 00:00:00 2001 From: Roy Anger Date: Wed, 18 Dec 2024 01:32:48 -0500 Subject: [PATCH] feat: Added basic instructions to the doc --- ...ccounts.mdx => manage-sso-connections.mdx} | 33 ++++++++++++++----- docs/manifest.json | 4 +-- 2 files changed, 26 insertions(+), 11 deletions(-) rename docs/custom-flows/{manage-oauth-accounts.mdx => manage-sso-connections.mdx} (66%) diff --git a/docs/custom-flows/manage-oauth-accounts.mdx b/docs/custom-flows/manage-sso-connections.mdx similarity index 66% rename from docs/custom-flows/manage-oauth-accounts.mdx rename to docs/custom-flows/manage-sso-connections.mdx index 7fa61d9eab..fcfb3c2dcb 100644 --- a/docs/custom-flows/manage-oauth-accounts.mdx +++ b/docs/custom-flows/manage-sso-connections.mdx @@ -1,8 +1,24 @@ --- -title: Build a custom flow for managing external accounts -description: Learn how to use the Clerk API to build a custom flow for adding and managing OAuth accounts +title: Build a custom flow for managing SSO connections +description: Learn how to use the Clerk API to build a custom flow for adding and managing SSO connections --- + + ## Enable one or more SSO connections + + For your users to be able to add or manage OAuth connections, you will ned to enable one or more SSO connections. + + 1. In the Clerk Dashboard, navigate to the [SSO connections](https://dashboard.clerk.com/last-active?path=user-authentication/sso-connections) page. + 1. Ensure there is at least one enabled SSO connections. + 1. Use the `Add connections` button to enable SSO connections. + + ## Edit the `options` array + + 1. Edit the `options` array in the code below to add all of your enabled SSO connections. + 1. The `OAuthStrategy` lists all of the strategies for the pre-configured SSO connections. + 1. Custom SSO connections will use a strategy like `oauth_custom_`. The `OAuthStrategy` type includes typing for custom providers. The code example below will need modifying to support custom providers. + + ```tsx {{ filename: 'app/account/manage-external-accounts/page.tsx', collapsible: true }} 'use client' @@ -10,7 +26,7 @@ import { UserButton, useUser } from '@clerk/nextjs' import { OAuthStrategy } from '@clerk/types' import { useRouter } from 'next/navigation' -const capitalizeProvider = (provider: string) => { +const capitalize = (provider: string) => { return `${provider.slice(0, 1).toUpperCase()}${provider.slice(1)}` } @@ -22,7 +38,7 @@ export default function AddAccount() { const options: OAuthStrategy[] = ['oauth_discord', 'oauth_google', 'oauth_github'] // handle adding the new external account - const addOAuth = async (strategy: OAuthStrategy) => { + const addSSO = async (strategy: OAuthStrategy) => { await user ?.createExternalAccount({ strategy, @@ -67,11 +83,10 @@ export default function AddAccount() { {user?.externalAccounts.map((account) => { return ( - {capitalizeProvider(account.provider)} + {capitalize(account.provider)} {account.approvedScopes} - {account.verification?.status && - capitalizeProvider(account.verification?.status)} + {account.verification?.status && capitalize(account.verification?.status)} @@ -89,8 +104,8 @@ export default function AddAccount() { {unconnectedOptions.map((strategy) => { return (
  • -
  • ) diff --git a/docs/manifest.json b/docs/manifest.json index 3890a25479..376d823dd0 100644 --- a/docs/manifest.json +++ b/docs/manifest.json @@ -1757,8 +1757,8 @@ "href": "/docs/custom-flows/add-phone" }, { - "title": "Manage OAuth accounts", - "href": "/docs/custom-flows/manage-oauth-accounts" + "title": "Manage SSO connections", + "href": "/docs/custom-flows/manage-sso-connections" }, { "title": "Manage SMS-based MFA",