-
Couldn't load subscription status.
- Fork 851
Add SDK-specificity to Authentication flows, User management, and Session management sections #2595
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…in permissions Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
| app.get('/user', async (req, res) => { | ||
| // The `Auth` object gives you access to properties like `isAuthenticated` and `userId` | ||
| // Accessing the `Auth` object differs depending on the SDK you're using | ||
| // https://clerk.com/docs/reference/backend/types/auth-object#how-to-access-the-auth-object |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same "link as comment" note as above.
|
|
||
| // Initialize the JS Backend SDK | ||
| // This varies depending on the SDK you're using | ||
| // https://clerk.com/docs/js-backend/getting-started/quickstart |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same "link as comment" note as above.
| const notionResponse = await fetch(notionUrl, { | ||
| headers: { | ||
| Authorization: `Bearer ${accessToken}`, | ||
| 'Notion-Version': '2022-06-28', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same old Notion version comment as above.
|
|
||
| // Initialize the JS Backend SDK | ||
| // This varies depending on the SDK you're using | ||
| // https://clerk.com/docs/js-backend/getting-started/quickstart |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same "link as comment" note as above.
| async function getNotionData(request) { | ||
| // The `Auth` object gives you access to properties like `isAuthenticated` and `userId` | ||
| // Accessing the `Auth` object differs depending on the SDK you're using | ||
| // https://clerk.com/docs/reference/backend/types/auth-object#how-to-access-the-auth-object |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same "link as comment" note as above.
| const notionResponse = await fetch(notionUrl, { | ||
| headers: { | ||
| Authorization: `Bearer ${accessToken}`, | ||
| 'Notion-Version': '2022-06-28', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same old Notion version comment as above.
| export async function loader(args: Route.LoaderArgs) { | ||
| // The `Auth` object gives you access to properties like `isAuthenticated` and `userId` | ||
| // Accessing the `Auth` object differs depending on the SDK you're using | ||
| // https://clerk.com/docs/reference/backend/types/auth-object#how-to-access-the-auth-object |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same "link as comment" note as above.
|
|
||
| // Initialize the JS Backend SDK | ||
| // This varies depending on the SDK you're using | ||
| // https://clerk.com/docs/js-backend/getting-started/quickstart |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same "link as comment" note as above.
| const notionResponse = await fetch(notionUrl, { | ||
| headers: { | ||
| Authorization: `Bearer ${accessToken}`, | ||
| 'Notion-Version': '2022-06-28', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same old Notion version comment as above.
| GET: async () => { | ||
| // The `Auth` object gives you access to properties like `isAuthenticated` and `userId` | ||
| // Accessing the `Auth` object differs depending on the SDK you're using | ||
| // https://clerk.com/docs/reference/backend/types/auth-object#how-to-access-the-auth-object |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same "link as comment" note as above.
|
|
||
| // Initialize the JS Backend SDK | ||
| // This varies depending on the SDK you're using | ||
| // https://clerk.com/docs/js-backend/getting-started/quickstart |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same "link as comment" note as above.
| const notionResponse = await fetch(notionUrl, { | ||
| headers: { | ||
| Authorization: `Bearer ${accessToken}`, | ||
| 'Notion-Version': '2022-06-28', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same old Notion version comment as above.
|
|
||
| // Use the JS Backend SDK to get the user's OAuth access token | ||
| const clerkResponse = await client.users.getUserOauthAccessToken(userId, provider) | ||
| const accessToken = clerkResponse.data[0].token || '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The previous example was doing the same thing, but do we need to guard against data[0] here (and in all the examples below)? Will it ever not be an array? What if the userId is not found?
| <If sdk="nextjs"> | ||
| For `auth.protect()`, signed-out users will be redirected to the sign-in page. In the following example, `pending` users will be redirected to the sign-in page, where the `<SignIn />` component will prompt them to fulfill the session tasks. Once finished, their session will move from `pending` to an `active` (signed-in) state. | ||
| ```tsx {{ filename: 'middleware.ts', mark: [[6, 8]] }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be proxy.ts now? If true, do we need to update Middleware references to Proxy in this file too?
| export default async function Page() { | ||
| // The `Auth` object gives you access to properties like `isAuthenticated` and `userId` | ||
| // Accessing the `Auth` object differs depending on the SDK you're using | ||
| // https://clerk.com/docs/reference/backend/types/auth-object#how-to-access-the-auth-object |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same "link as comment" note as above.
| export const POST = async () => { | ||
| // `treatPendingAsSignedOut` is set to `false` to allow access to the `userId` for pending sessions | ||
| // Accessing the `Auth` object differs depending on the SDK you're using | ||
| // https://clerk.com/docs/reference/backend/types/auth-object#how-to-access-the-auth-object |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same "link as comment" note as above.
| export async function GET(req: Request) { | ||
| // Initialize the JS Backend SDK | ||
| // This varies depending on the SDK you're using | ||
| // https://clerk.com/docs/js-backend/getting-started/quickstart |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same "link as comment" note as above.
|
|
||
| // Initialize the JS Backend SDK | ||
| // This varies depending on the SDK you're using | ||
| // https://clerk.com/docs/js-backend/getting-started/quickstart |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same "link as comment" note as above.
| <Tab> | ||
| If you are using the [JS Backend SDK](/docs/js-backend/getting-started/quickstart) on its own, you need to provide the `secretKey` and `publishableKey` to `createClerkClient()` so that it is passed to `authenticateRequest()`. You can set these values as [environment variables](/docs/guides/development/clerk-environment-variables#clerk-publishable-and-secret-keys) and then pass them to the function. | ||
|
|
||
| <Include src="_partials/authenticate-req" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is just this one in a partial and not the rest?
| // Use `auth()` to access `isAuthenticated` and the user's ID | ||
| // The `Auth` object gives you access to properties like `isAuthenticated` and `userId` | ||
| // Accessing the `Auth` object differs depending on the SDK you're using | ||
| // https://clerk.com/docs/reference/backend/types/auth-object#how-to-access-the-auth-object |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same "link as comment" note as above.
|
|
||
| // Initialize the JS Backend SDK | ||
| // This varies depending on the SDK you're using | ||
| // https://clerk.com/docs/js-backend/getting-started/quickstart |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same "link as comment" note as above.
| // Use `locals.auth()` to access `isAuthenticated` and the user's ID | ||
| // The `Auth` object gives you access to properties like `isAuthenticated` and `userId` | ||
| // Accessing the `Auth` object differs depending on the SDK you're using | ||
| // https://clerk.com/docs/reference/backend/types/auth-object#how-to-access-the-auth-object |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same "link as comment" note as above.
| // Use the JS Backend SDK's `getUser()` method to get the Backend User object | ||
| // Initialize the JS Backend SDK | ||
| // This varies depending on the SDK you're using | ||
| // https://clerk.com/docs/js-backend/getting-started/quickstart |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same "link as comment" note as above.
| // Use `getAuth()` to access `isAuthenticated` and the user's ID | ||
| // The `Auth` object gives you access to properties like `isAuthenticated` and `userId` | ||
| // Accessing the `Auth` object differs depending on the SDK you're using | ||
| // https://clerk.com/docs/reference/backend/types/auth-object#how-to-access-the-auth-object |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same "link as comment" note as above.
| // Use the JS Backend SDK's `getUser()` method to get the Backend User object | ||
| // Initialize the JS Backend SDK | ||
| // This varies depending on the SDK you're using | ||
| // https://clerk.com/docs/js-backend/getting-started/quickstart |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same "link as comment" note as above.
| // Use `getAuth()` to access `isAuthenticated` and the user's ID | ||
| // The `Auth` object gives you access to properties like `isAuthenticated` and `userId` | ||
| // Accessing the `Auth` object differs depending on the SDK you're using | ||
| // https://clerk.com/docs/reference/backend/types/auth-object#how-to-access-the-auth-object |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same "link as comment" note as above.
| // Get the Backend User object | ||
| // Initialize the JS Backend SDK | ||
| // This varies depending on the SDK you're using | ||
| // https://clerk.com/docs/js-backend/getting-started/quickstart |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same "link as comment" note as above.
| GET: async () => { | ||
| // The `Auth` object gives you access to properties like `isAuthenticated` and `userId` | ||
| // Accessing the `Auth` object differs depending on the SDK you're using | ||
| // https://clerk.com/docs/reference/backend/types/auth-object#how-to-access-the-auth-object |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same "link as comment" note as above.
|
|
||
| // Initialize the JS Backend SDK | ||
| // This varies depending on the SDK you're using | ||
| // https://clerk.com/docs/js-backend/getting-started/quickstart |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same "link as comment" note as above.
| ## Create an invitation | ||
|
|
||
| You can create an invitation in the [Clerk Dashboard](#using-clerk-dashboard) or [using the Backend API](#using-backend-api). | ||
| You can create an invitation either in the [Clerk Dashboard](#in-the-clerk-dashboard) or [programmatically](#programmatically). When making this decision, keep in mind that if you create an invitation through the Clerk Dashboard, you can only set an invitation expiration date. If you create an invitation programatically, you are able to set more options, such as the URL you want the user to be redirected to after they accept the invitation, metadata to add to the invitation, or whether an invitation should be created if there is already an existing invitation for the given email address. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand that we're documenting how it currently works, but this feels like we should push to have these capabilities available via the dashboard too.
🔎 Previews:
Tip
Just to note that the most used SDKs in order: nextjs, react, express, expo, javascript, js backend
What changed?
{{ target: '_blank' }}following themFIXES DOCS-11112
Checklist