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) (or maybe .getUserByDiscordId(discordUserID) or .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,
);

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.
}
Was this page helpful?