Table of Contents

Class Api

Namespace
Supabase.Gotrue
Assembly
Supabase.Gotrue.dll

The REST calls to the Gotrue API.

public class Api : IGotrueApi<User, Session>, IGettableHeaders
Inheritance
Api
Implements
IGettableHeaders
Inherited Members

Constructors

Api(string, Dictionary<string, string>?)

Creates a new API client

public Api(string url, Dictionary<string, string>? headers = null)

Parameters

url string
headers Dictionary<string, string>

Properties

GetHeaders

Function that can be set to return dynamic headers. Headers specified in the constructor will ALWAYS take precedence over headers returned by this function.

public Func<Dictionary<string, string>>? GetHeaders { get; set; }

Property Value

Func<Dictionary<string, string>>

Headers

Headers to be sent with every request. These will be merged with any headers returned by GetHeaders.

protected Dictionary<string, string> Headers { get; set; }

Property Value

Dictionary<string, string>

Methods

Challenge(string, MfaChallengeParams)

public Task<MfaChallengeResponse?> Challenge(string jwt, MfaChallengeParams mfaChallengeParams)

Parameters

jwt string
mfaChallengeParams MfaChallengeParams

Returns

Task<MfaChallengeResponse>

CreateUser(string, AdminUserAttributes?)

Create a user

public Task<User?> CreateUser(string jwt, AdminUserAttributes? attributes = null)

Parameters

jwt string

A valid JWT. Must be a full-access API key (e.g. service_role key).

attributes AdminUserAttributes

Additional administrative details

Returns

Task<User>

DeleteFactor(string, MfaAdminDeleteFactorParams)

public Task<MfaAdminDeleteFactorResponse?> DeleteFactor(string jwt, MfaAdminDeleteFactorParams deleteFactorParams)

Parameters

jwt string
deleteFactorParams MfaAdminDeleteFactorParams

Returns

Task<MfaAdminDeleteFactorResponse>

DeleteUser(string, string)

Delete a user

public Task<BaseResponse> DeleteUser(string uid, string jwt)

Parameters

uid string

The user uid you want to remove.

jwt string

A valid JWT. Must be a full-access API key (e.g. service_role key).

Returns

Task<BaseResponse>

Enroll(string, MfaEnrollParams)

public Task<MfaEnrollResponse?> Enroll(string jwt, MfaEnrollParams mfaEnrollParams)

Parameters

jwt string
mfaEnrollParams MfaEnrollParams

Returns

Task<MfaEnrollResponse>

ExchangeCodeForSession(string, string)

Log in an existing user via code from third-party provider.

public Task<Session?> ExchangeCodeForSession(string codeVerifier, string authCode)

Parameters

codeVerifier string

Generated verifier (probably from GetUrlForProvider)

authCode string

The received Auth Code Callback

Returns

Task<Session>

Generates email links and OTPs to be sent via a custom email provider.

public Task<BaseResponse> GenerateLink(string jwt, GenerateLinkOptions options)

Parameters

jwt string
options GenerateLinkOptions

Returns

Task<BaseResponse>

GetUriForProvider(Provider, SignInOptions?)

public ProviderAuthState GetUriForProvider(Constants.Provider provider, SignInOptions? options = null)

Parameters

provider Constants.Provider
options SignInOptions

Returns

ProviderAuthState

GetUser(string)

Gets User Details

public Task<User?> GetUser(string jwt)

Parameters

jwt string

Returns

Task<User>

GetUserById(string, string)

Get User details by Id

public Task<User?> GetUserById(string jwt, string userId)

Parameters

jwt string

A valid JWT. Must be a full-access API key (e.g. service_role key).

userId string

userID

Returns

Task<User>

InviteUserByEmail(string, string, InviteUserByEmailOptions?)

Sends an invite link to an email address.

public Task<BaseResponse> InviteUserByEmail(string email, string jwt, InviteUserByEmailOptions? options = null)

Parameters

email string
jwt string

this token needs role 'supabase_admin' or 'service_role'

options InviteUserByEmailOptions

Returns

Task<BaseResponse>

LinkIdentity(string, Provider, SignInOptions)

Links an oauth identity to an existing user.

This method requires the PKCE flow.

public Task<ProviderAuthState> LinkIdentity(string token, Constants.Provider provider, SignInOptions options)

Parameters

token string

User's token

provider Constants.Provider

Provider to Link

options SignInOptions

Returns

Task<ProviderAuthState>

ListFactors(string, MfaAdminListFactorsParams)

public Task<BaseResponse> ListFactors(string jwt, MfaAdminListFactorsParams listFactorsParams)

Parameters

jwt string
listFactorsParams MfaAdminListFactorsParams

Returns

Task<BaseResponse>

ListUsers(string, string?, string?, SortOrder, int?, int?)

Lists users

public Task<UserList<User>?> ListUsers(string jwt, string? filter = null, string? sortBy = null, Constants.SortOrder sortOrder = SortOrder.Descending, int? page = null, int? perPage = null)

Parameters

jwt string

A valid JWT. Must be a full-access API key (e.g. service_role key).

filter string

A string for example part of the email

sortBy string

Snake case string of the given key, currently only created_at is supported

sortOrder Constants.SortOrder

asc or desc, if null desc is used

page int?

page to show for pagination

perPage int?

items per page for pagination

Returns

Task<UserList<User>>

Reauthenticate(string)

Sends a re-authentication request, used for password changes.

See: https://github.com/supabase/gotrue#get-reauthenticate

public Task<BaseResponse> Reauthenticate(string userJwt)

Parameters

userJwt string

The user's auth token.

Returns

Task<BaseResponse>

RefreshAccessToken(string, string)

Generates a new Session given a user's access token and refresh token.

public Task<Session?> RefreshAccessToken(string accessToken, string refreshToken)

Parameters

accessToken string
refreshToken string

Returns

Task<Session>

ResetPasswordForEmail(ResetPasswordForEmailOptions)

Sends a password reset request to an email address.

This Method supports the PKCE Flow

public Task<ResetPasswordForEmailState> ResetPasswordForEmail(ResetPasswordForEmailOptions options)

Parameters

options ResetPasswordForEmailOptions

Returns

Task<ResetPasswordForEmailState>

ResetPasswordForEmail(string)

Sends a reset request to an email address.

public Task<BaseResponse> ResetPasswordForEmail(string email)

Parameters

email string

Returns

Task<BaseResponse>

SendMagicLinkEmail(string, SignInOptions?)

Sends a magic login link to an email address.

public Task<BaseResponse> SendMagicLinkEmail(string email, SignInOptions? options = null)

Parameters

email string
options SignInOptions

Returns

Task<BaseResponse>

SendMobileOTP(string)

Sends a mobile OTP via SMS. Will register the account if it doesn't already exist

public Task<BaseResponse> SendMobileOTP(string phone)

Parameters

phone string

phone The user's phone number WITH international prefix

Returns

Task<BaseResponse>

Settings()

Calls the GoTrue server to get the settings (for example, if email auto confirmation is turned on)

public Task<Settings?> Settings()

Returns

Task<Settings>

mpose up -d

SignInAnonymously(SignInAnonymouslyOptions?)

Creates a new anonymous user.

public Task<Session?> SignInAnonymously(SignInAnonymouslyOptions? options = null)

Parameters

options SignInAnonymouslyOptions

Returns

Task<Session>

A session where the is_anonymous claim in the access token JWT set to true

SignInWithEmail(string, string)

Logs in an existing user using their email address.

public Task<Session?> SignInWithEmail(string email, string password)

Parameters

email string
password string

Returns

Task<Session>

SignInWithIdToken(Provider, string, string?, string?, string?)

Allows signing in with an ID token issued by certain supported providers. The [idToken] is verified for validity and a new session is established. This method of signing in only supports [Provider.Google] or [Provider.Apple].

public Task<Session?> SignInWithIdToken(Constants.Provider provider, string idToken, string? accessToken = null, string? nonce = null, string? captchaToken = null)

Parameters

provider Constants.Provider

A supported provider (Google, Apple, Azure, Facebook)

idToken string

OIDC ID token issued by the specified provider. The iss claim in the ID token must match the supplied provider. Some ID tokens contain an at_hash which require that you provide an access_token value to be accepted properly. If the token contains a nonce claim you must supply the nonce used to obtain the ID token.

accessToken string

If the ID token contains an at_hash claim, then the hash of this value is compared to the value in the ID token.

nonce string

If the ID token contains a nonce claim, then the hash of this value is compared to the value in the ID token.

captchaToken string

Verification token received when the user completes the captcha on the site.

Returns

Task<Session>

SignInWithOtp(SignInWithPasswordlessEmailOptions)

Log in a user using magiclink or a one-time password (OTP).

If the {{ .ConfirmationURL }} variable is specified in the email template, a magiclink will be sent. If the {{ .Token }} variable is specified in the email template, an OTP will be sent. If you're using phone sign-ins, only an OTP will be sent. You won't be able to send a magiclink for phone sign-ins.

Be aware that you may get back an error message that will not distinguish between the cases where the account does not exist or, that the account can only be accessed via social login.

Do note that you will need to configure a Whatsapp sender on Twilio if you are using phone sign in with the 'whatsapp' channel. The whatsapp channel is not supported on other providers at this time.

public Task<PasswordlessSignInState> SignInWithOtp(SignInWithPasswordlessEmailOptions options)

Parameters

options SignInWithPasswordlessEmailOptions

Returns

Task<PasswordlessSignInState>

SignInWithOtp(SignInWithPasswordlessPhoneOptions)

Log in a user using magiclink or a one-time password (OTP).

If the {{ .ConfirmationURL }} variable is specified in the email template, a magiclink will be sent. If the {{ .Token }} variable is specified in the email template, an OTP will be sent. If you're using phone sign-ins, only an OTP will be sent. You won't be able to send a magiclink for phone sign-ins.

Be aware that you may get back an error message that will not distinguish between the cases where the account does not exist or, that the account can only be accessed via social login.

Do note that you will need to configure a Whatsapp sender on Twilio if you are using phone sign in with the 'whatsapp' channel. The whatsapp channel is not supported on other providers at this time.

public Task<PasswordlessSignInState> SignInWithOtp(SignInWithPasswordlessPhoneOptions options)

Parameters

options SignInWithPasswordlessPhoneOptions

Returns

Task<PasswordlessSignInState>

SignInWithPhone(string, string)

Logs in an existing user using their phone number and password.

public Task<Session?> SignInWithPhone(string phone, string password)

Parameters

phone string

The phone number of the user.

password string

The password of the user.

Returns

Task<Session>

SignInWithSSO(Guid, SignInWithSSOOptions?)

public Task<SSOResponse?> SignInWithSSO(Guid providerId, SignInWithSSOOptions? options = null)

Parameters

providerId Guid
options SignInWithSSOOptions

Returns

Task<SSOResponse>

SignInWithSSO(string, SignInWithSSOOptions?)

public Task<SSOResponse?> SignInWithSSO(string domain, SignInWithSSOOptions? options = null)

Parameters

domain string
options SignInWithSSOOptions

Returns

Task<SSOResponse>

SignOut(string, SignOutScope)

Removes a logged-in session.

public Task<BaseResponse> SignOut(string jwt, Constants.SignOutScope scope = SignOutScope.Global)

Parameters

jwt string
scope Constants.SignOutScope

Returns

Task<BaseResponse>

SignUpWithEmail(string, string, SignUpOptions?)

Signs a user up using an email address and password.

public Task<Session?> SignUpWithEmail(string email, string password, SignUpOptions? options = null)

Parameters

email string
password string
options SignUpOptions

Optional Signup data.

Returns

Task<Session>

SignUpWithPhone(string, string, SignUpOptions?)

Signs up a new user using their phone number and a password.The phone number of the user.

public Task<Session?> SignUpWithPhone(string phone, string password, SignUpOptions? options = null)

Parameters

phone string

The phone number of the user.

password string

The password of the user.

options SignUpOptions

Optional Signup data.

Returns

Task<Session>

Unenroll(string, MfaUnenrollParams)

public Task<MfaUnenrollResponse?> Unenroll(string jwt, MfaUnenrollParams mfaUnenrollParams)

Parameters

jwt string
mfaUnenrollParams MfaUnenrollParams

Returns

Task<MfaUnenrollResponse>

UnlinkIdentity(string, UserIdentity)

Unlinks an identity from a user by deleting it. The user will no longer be able to sign in with that identity once it's unlinked.

public Task<bool> UnlinkIdentity(string token, UserIdentity userIdentity)

Parameters

token string

User's token

userIdentity UserIdentity

Identity to be unlinked

Returns

Task<bool>

UpdateUser(string, UserAttributes)

Updates the User data

public Task<User?> UpdateUser(string jwt, UserAttributes attributes)

Parameters

jwt string
attributes UserAttributes

Returns

Task<User>

UpdateUserById(string, string, UserAttributes)

Update user by Id

public Task<User?> UpdateUserById(string jwt, string userId, UserAttributes userData)

Parameters

jwt string

A valid JWT. Must be a full-access API key (e.g. service_role key).

userId string

userID

userData UserAttributes

User attributes e.g. email, password, etc.

Returns

Task<User>

Verify(string, MfaVerifyParams)

public Task<MfaVerifyResponse?> Verify(string jwt, MfaVerifyParams mfaVerifyParams)

Parameters

jwt string
mfaVerifyParams MfaVerifyParams

Returns

Task<MfaVerifyResponse>

VerifyEmailOTP(string, string, EmailOtpType)

Send User supplied Email OTP to be verified

public Task<Session?> VerifyEmailOTP(string email, string token, Constants.EmailOtpType type)

Parameters

email string

The user's email address

token string

token that user was sent to their mobile phone

type Constants.EmailOtpType

Type of verification, e.g. invite, recovery, etc.

Returns

Task<Session>

VerifyMobileOTP(string, string, MobileOtpType)

Send User supplied Mobile OTP to be verified

public Task<Session?> VerifyMobileOTP(string phone, string token, Constants.MobileOtpType type)

Parameters

phone string

The user's phone number WITH international prefix

token string

token that user was sent to their mobile phone

type Constants.MobileOtpType

e.g. SMS or phone change

Returns

Task<Session>

VerifyTokenHash(string, EmailOtpType)

Verify token hash used in an email confirmation link.

public Task<Session?> VerifyTokenHash(string tokenHash, Constants.EmailOtpType type)

Parameters

tokenHash string

The token hash used in an email confirmation link

type Constants.EmailOtpType

Type of verification, e.g. email.

Returns

Task<Session>