Resolving Discord ID during flow
I'm using BetterAuth as my Oauth handler.
What I want to be able to do is extract the authorised users Discord Snowflake User ID during the process to save to my database (prisma).
After some digging, I never see that value get exposed.
Is this possible?
12 Replies
You can run
listAccounts
(docs: https://www.better-auth.com/docs/concepts/users-accounts#list-user-accounts) and then find the discord provider, then look for the accountId, as this is the discord user idUser & Accounts | Better Auth
User and account management.
👀 I'll take a look at this now, thanks for the swift reply
It seems I have a session user (following Discord OAuth) but this method
-# from
Is throwing unauthorised? :think:
Are you logged in?
Yes, my session info reflects the account I logged in with
I've got a pretty basic page setup for what I'm going for
You're using authClient in a RSC
It's ran on the server
🤦♂️ i see
auth.api.listAccounts should fix it ;)
Don't forget to pass headers
do i need to await them 3 separate times or can i save the headers on a page load / capture

I'm not sure what you mean
as in - literally just const headers = await headers()
is that fine to do or non-advisable?
Yeah that should be fine, I don't think it's actually asynchronous, it's mostly there for Next to identify that component to be RSC
But yeah
Thanks for the help! That saved further headache