madjae
madjae14mo ago

Inconsistent auth status between convex and clerk.

Trying to understand how to solve this issue. Auth using clerk. Clerk setup with JWT templates for convex. auth.config.ts setup with correct values, and is consistent with auth settings within Convex dashboard. Clerk logs in fine (and same with create new), and reports isAuthenticated = true, however using Convex it always returns isAuthenticated = false.
22 Replies
madjae
madjaeOP14mo ago
I should note also that the isLoading changes to true (useConvexAuth) and then back to false. I do get the following message in console: Failed to authenticate: "No auth provider found matching the given token", check your server auth config
Michal Srb
Michal Srb14mo ago
Hey @madjae , did you follow the Convex setup guide? https://docs.convex.dev/auth/clerk#get-started
Convex Clerk | Convex Developer Hub
Clerk is an authentication platform providing login via
madjae
madjaeOP14mo ago
yes indeed Seems like I'm 99% there. Just bizarre that clerk is saying authenticated but convex is not.
Michal Srb
Michal Srb14mo ago
You need to use auth.config.js, not auth.config.ts If you are using .js, then something is wrong with the values in it
madjae
madjaeOP14mo ago
export default { providers: [ { domain: "https://xxx-xxx-99.accounts.dev", applicationID: "convex", }, ], }; obviously xxx is an obstruction
Michal Srb
Michal Srb14mo ago
And the file name ends in "js" ?
madjae
madjaeOP14mo ago
correct. auth.config.js
Michal Srb
Michal Srb14mo ago
Have you deployed? npx convex dev is running? (assuming this is a dev deployment setup)
madjae
madjaeOP14mo ago
correct - dev environment. npx convex dev is running and showing no errors.
Michal Srb
Michal Srb14mo ago
What do your dashboard logs show?
Michal Srb
Michal Srb14mo ago
No description
madjae
madjaeOP14mo ago
No description
madjae
madjaeOP14mo ago
Console logs show this during login:
No description
Michal Srb
Michal Srb14mo ago
Your frontend is definitely talking to the backend you're configuring? If you change documents:getById your web app reflects the changes?
madjae
madjaeOP14mo ago
I'm not seeing changes reflected. It seems websocket is failing auth thus the error above
Michal Srb
Michal Srb14mo ago
Well any functions not relying on ctx.auth.getUserIdentity() should continue to work
Michal Srb
Michal Srb14mo ago
Can you also check this settings page on your Convex dashboard
No description
madjae
madjaeOP14mo ago
Yep it has the same values as per the auth.config.js file
Michal Srb
Michal Srb14mo ago
Nice. On your website you can double check which backend your app is talking to in the network tab:
No description
Michal Srb
Michal Srb14mo ago
The wss:// address should match the URL of your convex dashboard (the deployment name is shown in both) If all of that lines up, then I would double check your publishableKey passed to ConvexProviderWithClerk is the right one, from the same Clerk instance you got your issuer URL in your auth.config.js
madjae
madjaeOP14mo ago
Ah I think you found the issue. WS is pointing to an older domain name. Must be cached somewhere?!?
Michal Srb
Michal Srb14mo ago
Check your CONVEX_URL that is passed to ConvexReactClient Usually it comes from your .env.local file (depends on your client setup) If the file is wrong you can copy the right URL from the Settings page

Did you find this page helpful?