How do I authenticate a query?
I'm trying to use convex-auth in svelte, I'm retreiving the accessToken as follows, this gives me a token and a refreshToken
however when trying to retrieve the current user, through
const me = await client.query(api.users.currentUser, {});
for the API
it always returns null3 Replies
Thanks for posting in <#1088161997662724167>.
Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets.
- Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.)
- Use search.convex.dev to search Docs, Stack, and Discord all at once.
- Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI.
- Avoid tagging staff unless specifically instructed.
Thank you!
The token needs to be hooked up to the Convex client via the
client.setAuth
method. I'm not super familiar with Svelte, but here's how the React set up works: https://github.com/get-convex/convex-js/blob/58dc97eebb608de28e0c39ae00c5beadc63773b7/src/react/ConvexAuthState.tsx#L151GitHub
convex-js/src/react/ConvexAuthState.tsx at 58dc97eebb608de28e0c39ae...
TypeScript/JavaScript client library for Convex. Contribute to get-convex/convex-js development by creating an account on GitHub.
thank you
for anyone reading, if
client.setAuth
is throwing errors, odds are you've misconfigured your JWKS env var