ninjz
ninjz4w ago

Is auth context passed to scheduled actions from server side queries/mutations?

I'm calling an action within a server side mutation using:
await ctx.scheduler.runAfter(
0,
api.test.testFn,
testData,
);
await ctx.scheduler.runAfter(
0,
api.test.testFn,
testData,
);
However when trying to retrieve the userIdentity within the action via:
const identity = await ctx.auth.getUserIdentity();
const identity = await ctx.auth.getUserIdentity();
It returns null. Is the auth context only passed to the action when the action is called directly from the client? Or am I doing something wrong? I'm using Convex Auth btw.
3 Replies
Convex Bot
Convex Bot4w 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!
lee
lee4w ago
correct https://docs.convex.dev/scheduling/scheduled-functions#auth the idea is that the function might run later, so the user might no longer be authenticated
ninjz
ninjzOP4w ago
thanks @Lee. Maybe it would be good to link to that from the docs on Function/actions + internal fns

Did you find this page helpful?