Is it possible to retrieve the `UserIdenity` based on its subject?
Hi guys, Is it possible to retrieve the
UserIdenity
based on its subject, if so how?11 Replies
Say more about what you're trying to achieve.
Sure, I am listening for Clerk webhooks on 'user.created', 'user.updated' and 'user.deleted', each of them provide a Clerk id which is equal to subject on
event.data.id
, based on this I could get the userdata using the clerkClient like: const userClerk = await clerkClient.users.getUser(clerkUserId);
, but I was wondering if it was possible to retrieve the UserIdentity object based on the subject aka the event.data.id
.Ah, no, that's not possible. If you're using webhooks the data is coming in the event.
(I'll publish new docs for webhooks setup today)
Oh, okay. I was just wondering if that was possible.
That sounds amazing. Thank you very much.
Also I would like to ask a question about webhooks as Clerk support was not responding for quite a while. Sorry if this is irrelevant, just tell me if I should delete this. But I am not sure what are the types for
event.data.slug
on the Clerk 'email.created'
. As my IDE show that event.data.slug
is string | null | undefined
. I am not sure if I should define the type manually. I am not even sure what are all of the types.Hmm, I'm not sure about that, I can't find API reference for the events.
string | null | undefined
sounds reasonable, I know slugs are used for organizations, not sure how they're related to email.created
.This is one of the helpful reference I was able to find about it:
I think it would be better if they were typed as I need to retrieve thing such as the
otp_code
like so:Anyways, thank you very much for the work that you do. Convex support is awesome, fast and frendly. I really appriciate it.
The new webhooks docs: https://docs.convex.dev/auth/database-auth#set-up-webhooks
Storing Users in the Convex Database | Convex Developer Hub
You might want to store user information directly in your Convex database, for
Nice, my current setup is very similiar to this, so I do not need to update anything. I just have extra actions sto also sync the user to stripe.
The docs are very well written. Very nice.
I also throw when user can not be deleted etc... And send a 500 Internal server response so we notify Clerk about it and so it can resend the webhook etc..
Funny how i wanted to ask this same question and it was just answered yesterday and the docs also got updated!
Nice work @Michal Srb
And thanks to @cornpopguy for asking this question as it has saved me from my current roadblock lol.