Is it possible to get a user_id from a discord use...
# help-and-questions
a
I have a site with discord social auth enabled, but I need to get the referenced user_id (from
auth.users
via
auth.identities
), is it possible to get the user_id? Help
n
Perhaps, you can create a trigger on_user_create to insert into public.profile with user_id | discord_id
a
Hm, I figured
Thanks
Wait, how would I get the discord id from the new user event though?
n
Where is discord id stored?
You can have a ON INSERT and UPDATE trigger that checks for the discord_id and populate that field within the
public.profile
table if it exists
a
I'm just using the
signinwithOauth()
function
so it's in the
auth.identities
table
n
you can add the trigger ON that table then right?
I don't use social auth, but the process should work
a
good question
lemme try that
hm, no good on
new.raw_user_meta_data
at least
idk where to get the id
n
could you check this table?
g
Use
raise log 'my value = %',new;
in your trigger function and look in postgres logs to see all the values. But it would be whatever column name it is in for that table new.colname. I don't use OAuth either so not sure where it goes to. Some info like the OAuth access token are not stored at all for security reasons. I don't think that table has raw_user_meta_data like auth.users.
Looking at that table it almost has to be under the column identity_data if it is there.
a
good idea, thank you
Where umm... exactly are the logs?
g

https://cdn.discordapp.com/attachments/1111097762247884852/1111121874424971314/image.png

a
thanks -- I'm on local for dev, but I guess I'll just have to push
g
Yeah, it is there, but I don't do local either. It is in the file system somewhere. But if your trigger is on that table the new.xxx means .xxx is a column name in that table.