Skip to content

Move oauthTokens out of Session and make available via a new onSuccess option#154

Merged
mthadley merged 3 commits intomainfrom
feature/auth-4012-move-oauthtokens-out-of-authkit-next-session-cookie
Dec 19, 2024
Merged

Move oauthTokens out of Session and make available via a new onSuccess option#154
mthadley merged 3 commits intomainfrom
feature/auth-4012-move-oauthtokens-out-of-authkit-next-session-cookie

Conversation

@mthadley
Copy link
Contributor

This follows the pattern that was recently introduced in workos/authkit-remix#33:

Instead of storing these tokens in the session, this branch proposes making them only available as part of the initial > callback. Developers who need access to the underlying OAuth provider's tokens and API will be responsible for persisting them in their own data store for later usage.

The equivalent usage with workos/authkit-next looks like this:

import { handleAuth } from '@workos-inc/authkit-nextjs';

export const GET = handleAuth({
  onSuccess: async ({ oauthTokens }) => {
    await saveTokens(oauthTokens);
  },
});

@linear
Copy link

linear bot commented Dec 17, 2024

Copy link
Contributor

@PaulAsjes PaulAsjes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just some wordsmithing.

Co-authored-by: Paul Asjes <paul.asjes@workos.com>
@mthadley mthadley merged commit 565f393 into main Dec 19, 2024
@mthadley mthadley deleted the feature/auth-4012-move-oauthtokens-out-of-authkit-next-session-cookie branch December 19, 2024 23:34
@mthadley mthadley mentioned this pull request Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants