Storing users in Convex
What is the recommended way to create a user in a Convex table corresponding to each user from my IDP? I was doing this
but I'm upgrading Convex and now it wants an async
getIdToken function instead, and it seems the mutation does not wait for that token process to resolve, so I get an authentication error.4 Replies
Heh, I should have checked the docs first I guess 😅
https://docs.convex.dev/using/auth#storing-users-in-convex
Authentication | Convex Developer Hub
Add authentication to your Convex app.
useMutation fixed it. Though I'm surprised useMutation waits for the auth to finish but convex.mutation doesn't.getIdToken function, it fails every time.You can await the
setAuth call / do a .then() on the promise that it now returns
but I can understand the expectation that this the mutation would wait for the new auth
"if a mutation is invoked after a call to setAuth it will use a token returned from that new auth fetcher" seems fair, I can't think of a case where you wouldn't want this
sorry about the trouble here, look for a behavior change here in an upcoming releaseAh I thought I checked for a return value from
setAuth, but I guess I have weekend brain. 😅 That works, thanks so much!