Jczhang
Jczhang15mo ago

Using Clerk OAuth app with Convex? How to setAuth()?

I am following this for creating my own OAuth app through Clerk: https://clerk.com/docs/advanced-usage/clerk-idp from their tutorial it is clear that I can access /oauth/userinfo to get the userId. But I am not sure what is the access token format from Clerk (looks like it is not a convex compatible jwt) and what should I do if I want to use a convex client from backend. After I have the access token from Clerk OAuth or I already know the userId within the request, how to setAuth() for convex client? I don't know what jwt to pass in since I am using Clerk. Is there a super admin convex client that I can directly operate with known userId? Thanks for helping!
Use Clerk as an OAuth 2 Provider | Clerk
Learn how to use Clerk to facilitate Single Sign-On (SSO) with other clients that support the OAuth 2.0 protocol.
2 Replies
Michal Srb
Michal Srb15mo ago
Hey @Jczhang, is there any particular reason you are using this Clerk flow, and not the typical flow as shown here? https://clerk.com/docs/integrations/databases/convex#integrate-convex-with-clerk
Integrate Convex with Clerk | Clerk
Learn how to integrate Clerk into your Convex application.
Jczhang
JczhangOP15mo ago
Thank you @Michal Srb I figured this out. I am using Clerk OAuth from backend so cannot really use the provider here (btw on my frontend I also uses clerk convex provider with no problem). I am manually validating the access token from Clerk OAuth now and was able to use a password/apiKey to authenticate with my convex query. Thanks!

Did you find this page helpful?