supabase-rb-rb
Auth

Unlink an identity from a user

Unlink an OAuth identity from the current user.

Detach an OAuth identity from the currently signed-in user. Pass either a Supabase::Auth::Types::UserIdentity (typically read from get_user_identities) or a hash with an :identity_id key.

A session is required — unlink_identity raises Supabase::Auth::Errors::AuthSessionMissing if no user is signed in. The user must keep at least one identity; GoTrue rejects unlinking the last one.

Signature

supabase.auth.unlink_identity(identity)

identity is either a UserIdentity Struct (responds to #identity_id) or a Hash with :identity_id.

Parameters

NameTypeRequiredDescription
identitySupabase::Auth::Types::UserIdentity or HashRequiredThe identity to unlink. If a Struct, it must respond to #identity_id; if a Hash, it must contain :identity_id. Typically obtained from get_user_identities.

Returns

Returns
Hash

Returns the parsed GoTrue response body for DELETE /user/identities/:identity_id. On success the body is an empty hash; on failure the call raises Supabase::Auth::Errors::AuthApiError.

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

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

supabase.auth.unlink_identity(github)
supabase.auth.unlink_identity(identity_id: "d0a8b3a4-9e7f-4c2b-8b1c-3e7f6c2b1a9e")

Also accepts a plain Hash with :identity_id (handy when you've persisted the ID outside a UserIdentity Struct).

On this page