supabase-rb-rb
Auth

Retrieve identities linked to a user

List the OAuth identities linked to the current user.

Return the identities (email, phone, OAuth providers like Google or GitHub) currently linked to the signed-in user. Useful before calling unlink_identity — you need an identity_id to unlink, and that's a property of each UserIdentity in the list.

A session is required — get_user_identities raises Supabase::Auth::Errors::AuthSessionMissing if no user is signed in.

Signature

supabase.auth.get_user_identities

No arguments — the call always operates on the current session's user.

Parameters

None.

Returns

Returns
Supabase::Auth::Types::IdentitiesResponse

A Struct with a single :identities field — an Array of Supabase::Auth::Types::UserIdentity Structs. Each identity exposes :id, :identity_id, :user_id, :identity_data, :provider, :created_at, :last_sign_in_at, :updated_at.

Raises Supabase::Auth::Errors::AuthSessionMissing if there is no active session.

Example — list every identity

response = supabase.auth.get_user_identities

response.identities.each do |identity|
  puts "#{identity.provider}: #{identity.identity_data["email"] || identity.identity_data["phone"]}"
end

Example — find a specific provider

identities = supabase.auth.get_user_identities.identities
google = identities.find { |i| i.provider == "google" }

google&.identity_id   # => "..."
identities = supabase.auth.get_user_identities.identities

if identities.length > 1
  github = identities.find { |i| i.provider == "github" }
  supabase.auth.unlink_identity(github) if github
end

Calls auth.get_user under the hood and plucks user.identities into an IdentitiesResponse. Each identity matches the GoTrue wire format.

On this page