Issue with OAuth login for users authenticating through Patreon in a Next.js application using Clerk for authentication

User Switching Issue:

  • When switching from one Patreon user to another in my application, the app does not recognize the newly logged-in user. Instead, it continues to authenticate the previous user, even across different browsers.
  • Testing with other OAuth providers (e.g., Google) works as expected, suggesting the issue is specific to the integration with Patreon.
  • In clerk, the new user isn’t created.

Token and Session Behavior:

  • The session ID changes correctly upon logging in and out, ruling out session caching as a cause.
  • The behavior does not occur when logging in through email/password, further indicating a problem specific to the Patreon OAuth flow.

Debugging:

  • Logging in with a second account and making an API call fails with a 401 error when the first account is logged out, even though the second user is authenticated in a different browser. The userId from auth() (“@clerk/nextjs/server”) is the userId of the first account.

Here is my oauth settings:

Its difficult to say something with certainty because this seems to happen at your application. The api would give you the info of the user that belongs to whatever token you used to call it.

Looking into how your app handles sessions and whether anything that is involved in it is caching any type of session cookie etc may be productive.