adelin-b
adelin-b2mo ago

ContextHttpClient, setAuth, cannot get user from ctx

So im trying to call a query from the http client, and this query will need to be auth because we want to access ctx.getIdentity inside.
const convexHttpClient = new ConvexHttpClient(
process.env.NEXT_PUBLIC_CONVEX_URL!,

);

convexHttpClient.setAuth(config.authToken); // good token with template: "convex" that works when calling httpAction


const decks = await convexHttpClient.query(api.decks.list, {
organizationId: config.organizationId || null,
});
// ERROR inside the deck list query : const identity = await ctx.auth.getUserIdentity(); is NULL, expecting user

return decks;
const convexHttpClient = new ConvexHttpClient(
process.env.NEXT_PUBLIC_CONVEX_URL!,

);

convexHttpClient.setAuth(config.authToken); // good token with template: "convex" that works when calling httpAction


const decks = await convexHttpClient.query(api.decks.list, {
organizationId: config.organizationId || null,
});
// ERROR inside the deck list query : const identity = await ctx.auth.getUserIdentity(); is NULL, expecting user

return decks;
It seems that setAuth do nothing, how do I access ctx inside my deck.list query to have the user identity
1 Reply
Convex Bot
Convex Bot2mo ago
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!

Did you find this page helpful?