IsmailK
IsmailK12mo ago

Failed to authenticate No auth provider found matching the given token, check your server auth con

I followed the docs and setup auth with convex and clerk in my nextjs project, but I keep getting the same error. Here below you can see some code snippets and the console logs. The jwt token is showing up in the console but the auth error is still there. On the backend I did set the auth.config.ts and also copied the jwt template from clerk. But I am still stuck. Does anyone have a clue of what might be wrong?
No description
No description
No description
No description
19 Replies
Michal Srb
Michal Srb12mo ago
Debugging Authentication | Convex Developer Hub
You have followed one of our authentication guides but something is not working.
Michal Srb
Michal Srb12mo ago
Looking at your code, the problem is likely because you have ConvexReactClient client in two different modules You basically don't need the inner ConvexClientProvider
IsmailK
IsmailKOP12mo ago
I did go through the docs and read that part, but didnt realize the duplicate ConvexReactClient caused the issues. I will try your solution.... in the morning. I removed the inner ConvexReactClient, but the issue is still there. So I checked the network tab in the browser. And saw the following:
IsmailK
IsmailKOP12mo ago
No description
IsmailK
IsmailKOP12mo ago
It seems it connects and then disconnects
erquhart
erquhart12mo ago
Can you paste your updated AuthenticationProvider function body
IsmailK
IsmailKOP12mo ago
sure one second
IsmailK
IsmailKOP12mo ago
Here it is
No description
IsmailK
IsmailKOP12mo ago
I have also set the JWT issuer properly in the environement variables of convex. So I am not sure what could cause that error. I think I know what is wrong. I pushed the convex to production with clerks dev env variables as well yesterday night. I will fix that first. In the convex production the jwt issuer of clerk is the production jwt issuer , but in the authentication section the domain is the clerk dev env jwt issuer. That confuses me. How do I fix that?
erquhart
erquhart12mo ago
Authentication is depicting how to set up for dev I believe. Dev for dev, production for production. Let me know if I’m not understanding your question.
IsmailK
IsmailKOP12mo ago
I just need to know how to correct the authentication variables in the prod en dev environement of convex Right now the values in the authentication configuration of the convex prod are what should be in the convex dev. And in the convex dev there is no authentication configuration. Do I just delete the project and start over? I set up a new project in convex and clerk. This time I did not push anything to production on convex or clerk and I still get the same error. Which makes no sense. Again there is no authentication configuration in convex dev dashboard.
erquhart
erquhart12mo ago
I must be missing something here. Why can’t you update the configuration on the existing project? And the new project is going to have authentication errors if you don’t configure authentication. What am I missing?
IsmailK
IsmailKOP12mo ago
I just couldnt find in the docs how to update the authentication configuration I will close this, since I am switching to supabase.
Devben
Devben12mo ago
Same here am also facing the same error
erquhart
erquhart12mo ago
@IsmailK missed this one, if you still have any interest I'm happy to help you get auth figured out @Devben I know you have a couple of threads open, if this is a distinct issue from the others let's open a separate support forum post for it, don't want to get yours and the OP's issues confused
Devben
Devben12mo ago
I'm very sorry already open one but I need it asap and I couldn't wait that's why i message here but still trying the example one of the convex team gave to me... If I have any other problem about the clerk auth I'll message on the other thread thanks
erquhart
erquhart12mo ago
No problem!
Devben
Devben12mo ago
Now I think I need your help am messaging on the other threads thanks
ian
ian12mo ago
The auth config is specified in convex/auth.config.js in the code you deploy. If those use environment variables, like process.env.CLERK_ISSUER_URL then you set the environment variables in the appropriate prod/dev settings. e.g. https://dashboard.convex.dev/deployment/settings/environment-variables?var=CLERK_ISSUER_URL - there's a toggle at the top for dev vs. prod. For @IsmailK or @Devben or other future readers, it's part of step 4 here and here is a debugging guide. Hope that helps
Convex Clerk | Convex Developer Hub
Clerk is an authentication platform providing login via
Debugging Authentication | Convex Developer Hub
You have followed one of our authentication guides but something is not working.

Did you find this page helpful?