© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•3y ago•
12 replies
Trezy

Is there a way to get auth users based on their third-party login ID?

The Goal

When a role is added to a user in Discord, I'm trying to see if they also have a user in my Supabase Auth instance. If so, I'll end up creating some new roles in the database.

The Problem

I haven't found a way to query SupabaseAuth users based on their third party connections. Ideally, I could use
supabase.auth.admin.getUserById(discordUserID)
supabase.auth.admin.getUserById(discordUserID)
(or maybe
.getUserByDiscordId(discordUserID)
.getUserByDiscordId(discordUserID)
or
.getUserByThirdPartyId(discordUserID)
.getUserByThirdPartyId(discordUserID)
) to get the user based on their Discord ID, but from digging through the docs and the types that doesn't seem to exist. Am I missing something?

Potential Alternatives

If there's not a built-in solution for this, it seems like my best bet is to create a join table that gets updated whenever a new user is created for matching users to their connection IDs. Some thing like this...
CREATE TABLE [IF NOT EXISTS] userConnectionIDs (
  userID uuid generated always as identity primary key,
  discordID uuid unique,
  itchID uuid unique,
  patreonID uuid unique,
  githubID uuid unique,
);
CREATE TABLE [IF NOT EXISTS] userConnectionIDs (
  userID uuid generated always as identity primary key,
  discordID uuid unique,
  itchID uuid unique,
  patreonID uuid unique,
  githubID uuid unique,
);

That would allow me to use this table to get the correct user...
const result = await supabase
  .from('userConnectionIDs')
  .eq('discordID', discordID)
  .select()

const userConnectionIDs = result.data?[0]

if (userConnectionIDs) {
  const { userID } = result.data?[0]
  const user = await supabase.auth.admin.getUserById(userID)

  // TODO: Do things with the user record.
}
const result = await supabase
  .from('userConnectionIDs')
  .eq('discordID', discordID)
  .select()

const userConnectionIDs = result.data?[0]

if (userConnectionIDs) {
  const { userID } = result.data?[0]
  const user = await supabase.auth.admin.getUserById(userID)

  // TODO: Do things with the user record.
}
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

(Third Party Auth) Syncing Supabase users/organisations/entitlements with WorkOS
SupabaseSSupabase / help-and-questions
5mo ago
Is there a way to query for id by email on supabase auth table?
SupabaseSSupabase / help-and-questions
4y ago
Is there a way to keep users logged in?
SupabaseSSupabase / help-and-questions
13mo ago
Adding WeChat as Third Party Auth
SupabaseSSupabase / help-and-questions
8mo ago