Table of Contents

Class StatelessClient

Namespace
Supabase.Gotrue
Assembly
Supabase.Gotrue.dll

Supports all classes in the .NET class hierarchy and provides low-level services to derived classes. This is the ultimate base class of all .NET classes; it is the root of the type hierarchy.

public class StatelessClient : IGotrueStatelessClient<User, Session>
Inheritance
StatelessClient
Implements
Inherited Members
Extension Methods

Methods

Challenge(string, MfaChallengeParams, StatelessClientOptions)

Prepares a challenge used to verify that a user has access to a MFA factor.

public Task<MfaChallengeResponse?> Challenge(string jwt, MfaChallengeParams mfaChallengeParams, StatelessClient.StatelessClientOptions options)

Parameters

jwt string
mfaChallengeParams MfaChallengeParams
options StatelessClient.StatelessClientOptions

Returns

Task<MfaChallengeResponse>

ChallengeAndVerify(string, MfaChallengeAndVerifyParams, StatelessClientOptions)

Helper method which creates a challenge and immediately uses the given code to verify against it thereafter. The verification code is provided by the user by entering a code seen in their authenticator app.

public Task<MfaVerifyResponse?> ChallengeAndVerify(string jwt, MfaChallengeAndVerifyParams mfaChallengeAndVerifyParams, StatelessClient.StatelessClientOptions options)

Parameters

jwt string
mfaChallengeAndVerifyParams MfaChallengeAndVerifyParams
options StatelessClient.StatelessClientOptions

Returns

Task<MfaVerifyResponse>

CreateUser(string, StatelessClientOptions, AdminUserAttributes)

Create a user

public Task<User?> CreateUser(string serviceRoleToken, StatelessClient.StatelessClientOptions options, AdminUserAttributes attributes)

Parameters

serviceRoleToken string

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

options StatelessClient.StatelessClientOptions
attributes AdminUserAttributes

Returns

Task<User>

CreateUser(string, StatelessClientOptions, string, string, AdminUserAttributes?)

Create a user

public Task<User?> CreateUser(string serviceRoleToken, StatelessClient.StatelessClientOptions options, string email, string password, AdminUserAttributes? attributes = null)

Parameters

serviceRoleToken string

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

options StatelessClient.StatelessClientOptions
email string
password string
attributes AdminUserAttributes

Returns

Task<User>

DeleteUser(string, string, StatelessClientOptions)

Deletes a User.

public Task<bool> DeleteUser(string uid, string serviceRoleToken, StatelessClient.StatelessClientOptions options)

Parameters

uid string
serviceRoleToken string

this token needs role 'supabase_admin' or 'service_role'

options StatelessClient.StatelessClientOptions

Returns

Task<bool>

Enroll(string, MfaEnrollParams, StatelessClientOptions)

Starts the enrollment process for a new Multi-Factor Authentication (MFA) factor. This method creates a new unverified factor. To verify a factor, present the QR code or secret to the user and ask them to add it to their authenticator app. The user has to enter the code from their authenticator app to verify it.

Upon verifying a factor, all other sessions are logged out and the current session's authenticator level is promoted to aal2.

public Task<MfaEnrollResponse?> Enroll(string jwt, MfaEnrollParams mfaEnrollParams, StatelessClient.StatelessClientOptions options)

Parameters

jwt string
mfaEnrollParams MfaEnrollParams
options StatelessClient.StatelessClientOptions

Returns

Task<MfaEnrollResponse>

ExchangeCodeForSession(string, string, StatelessClientOptions)

Logs in an existing user via a third-party provider.

public Task<Session?> ExchangeCodeForSession(string codeVerifier, string authCode, StatelessClient.StatelessClientOptions options)

Parameters

codeVerifier string
authCode string
options StatelessClient.StatelessClientOptions

Returns

Task<Session>

GetApi(StatelessClientOptions)

Initialize/retrieve the underlying API for this client

public IGotrueApi<User, Session> GetApi(StatelessClient.StatelessClientOptions options)

Parameters

options StatelessClient.StatelessClientOptions

Returns

IGotrueApi<User, Session>

GetAuthenticatorAssuranceLevel(string, StatelessClientOptions)

Returns the Authenticator Assurance Level (AAL) for the active session.

  • aal1 (or null) means that the user's identity has been verified only with a conventional login (email+password, OTP, magic link, social login, etc.).
  • aal2 means that the user's identity has been verified both with a conventional login and at least one MFA factor.

Although this method returns a promise, it's fairly quick (microseconds) and rarely uses the network. You can use this to check whether the current user needs to be shown a screen to verify their MFA factors.

public Task<MfaGetAuthenticatorAssuranceLevelResponse?> GetAuthenticatorAssuranceLevel(string jwt, StatelessClient.StatelessClientOptions options)

Parameters

jwt string
options StatelessClient.StatelessClientOptions

Returns

Task<MfaGetAuthenticatorAssuranceLevelResponse>

GetSessionFromUrl(Uri, StatelessClientOptions)

Parses a Session out of a Uri's Query parameters.

public Task<Session?> GetSessionFromUrl(Uri uri, StatelessClient.StatelessClientOptions options)

Parameters

uri Uri
options StatelessClient.StatelessClientOptions

Returns

Task<Session>

GetUser(string, StatelessClientOptions)

Get User details by JWT. Can be used to validate a JWT.

public Task<User?> GetUser(string serviceRoleToken, StatelessClient.StatelessClientOptions options)

Parameters

serviceRoleToken string

A valid JWT. Must be a JWT that originates from a user.

options StatelessClient.StatelessClientOptions

Returns

Task<User>

GetUserById(string, StatelessClientOptions, string)

Get User details by Id

public Task<User?> GetUserById(string serviceRoleToken, StatelessClient.StatelessClientOptions options, string userId)

Parameters

serviceRoleToken string

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

options StatelessClient.StatelessClientOptions
userId string

Returns

Task<User>

InviteUserByEmail(string, string, StatelessClientOptions, InviteUserByEmailOptions?)

Sends an invite email link to the specified email.

public Task<bool> InviteUserByEmail(string email, string serviceRoleToken, StatelessClient.StatelessClientOptions options, InviteUserByEmailOptions? invitationOptions = null)

Parameters

email string
serviceRoleToken string

this token needs role 'supabase_admin' or 'service_role'

options StatelessClient.StatelessClientOptions
invitationOptions InviteUserByEmailOptions

Returns

Task<bool>

ListFactors(string, StatelessClientOptions)

Returns the list of MFA factors enabled for this user

public Task<MfaListFactorsResponse?> ListFactors(string jwt, StatelessClient.StatelessClientOptions options)

Parameters

jwt string
options StatelessClient.StatelessClientOptions

Returns

Task<MfaListFactorsResponse>

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

Lists users

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

Parameters

serviceRoleToken string

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

options StatelessClient.StatelessClientOptions
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>>

RefreshToken(string, string, StatelessClientOptions)

Refreshes a Token

public Task<Session?> RefreshToken(string accessToken, string refreshToken, StatelessClient.StatelessClientOptions options)

Parameters

accessToken string
refreshToken string
options StatelessClient.StatelessClientOptions

Returns

Task<Session>

ResetPasswordForEmail(string, StatelessClientOptions)

Sends a reset request to an email address.

public Task<bool> ResetPasswordForEmail(string email, StatelessClient.StatelessClientOptions options)

Parameters

email string
options StatelessClient.StatelessClientOptions

Returns

Task<bool>

Exceptions

Exception

Sends a Magic email login link to the specified email.

public Task<bool> SendMagicLink(string email, StatelessClient.StatelessClientOptions options, SignInOptions? signInOptions = null)

Parameters

email string
options StatelessClient.StatelessClientOptions
signInOptions SignInOptions

Returns

Task<bool>

Settings(StatelessClientOptions)

Retrieve the current settings for the Gotrue instance.

public Task<Settings?> Settings(StatelessClient.StatelessClientOptions options)

Parameters

options StatelessClient.StatelessClientOptions

Returns

Task<Settings>

SignIn(Provider, StatelessClientOptions, SignInOptions?)

Retrieves a Url to redirect to for signing in with a Constants.Provider.

This method will need to be combined with GetSessionFromUrl(Uri, StatelessClientOptions) when the Application receives the Oauth Callback.

public ProviderAuthState SignIn(Constants.Provider provider, StatelessClient.StatelessClientOptions options, SignInOptions? signInOptions = null)

Parameters

provider Constants.Provider
options StatelessClient.StatelessClientOptions
signInOptions SignInOptions

Returns

ProviderAuthState

Examples

var client = Supabase.Gotrue.Client.Initialize(options); var url = client.SignIn(Provider.Github);

// Do Redirect User

// Example code Application.HasReceivedOauth += async (uri) => { var session = await client.GetSessionFromUri(uri, true); }

SignIn(SignInType, string, string?, StatelessClientOptions?)

Log in an existing user, or login via a third-party provider.

public Task<Session?> SignIn(Constants.SignInType type, string identifierOrToken, string? password = null, StatelessClient.StatelessClientOptions? options = null)

Parameters

type Constants.SignInType

Type of Credentials being passed

identifierOrToken string

An email, phone, or RefreshToken

password string

Password to account (optional if RefreshToken)

options StatelessClient.StatelessClientOptions

Returns

Task<Session>

SignIn(string, StatelessClientOptions, SignInOptions?)

Sends a Magic email login link to the specified email.

public Task<bool> SignIn(string email, StatelessClient.StatelessClientOptions options, SignInOptions? signInOptions = null)

Parameters

email string
options StatelessClient.StatelessClientOptions
signInOptions SignInOptions

Returns

Task<bool>

SignIn(string, string, StatelessClientOptions)

Signs in a User with an email address and password.

public Task<Session?> SignIn(string email, string password, StatelessClient.StatelessClientOptions options)

Parameters

email string
password string
options StatelessClient.StatelessClientOptions

Returns

Task<Session>

SignOut(string, StatelessClientOptions)

Logout a User This will revoke all refresh tokens for the user. JWT tokens will still be valid for stateless auth until they expire.

public Task<bool> SignOut(string accessToken, StatelessClient.StatelessClientOptions options)

Parameters

accessToken string
options StatelessClient.StatelessClientOptions

Returns

Task<bool>

SignUp(SignUpType, string, string, StatelessClientOptions, SignUpOptions?)

Signs up a user

public Task<Session?> SignUp(Constants.SignUpType type, string identifier, string password, StatelessClient.StatelessClientOptions options, SignUpOptions? signUpOptions = null)

Parameters

type Constants.SignUpType

Type of signup

identifier string

Phone or Email

password string
options StatelessClient.StatelessClientOptions
signUpOptions SignUpOptions

Object containing redirectTo and optional user metadata (data)

Returns

Task<Session>

SignUp(string, string, StatelessClientOptions, SignUpOptions?)

Signs up a user by email address

public Task<Session?> SignUp(string email, string password, StatelessClient.StatelessClientOptions options, SignUpOptions? signUpOptions = null)

Parameters

email string
password string
options StatelessClient.StatelessClientOptions
signUpOptions SignUpOptions

Object containing redirectTo and optional user metadata (data)

Returns

Task<Session>

Unenroll(string, MfaUnenrollParams, StatelessClientOptions)

Unenroll removes a MFA factor. A user has to have an aal2 authenticator level in order to unenroll a verified factor.

public Task<MfaUnenrollResponse?> Unenroll(string jwt, MfaUnenrollParams mfaUnenrollParams, StatelessClient.StatelessClientOptions options)

Parameters

jwt string
mfaUnenrollParams MfaUnenrollParams
options StatelessClient.StatelessClientOptions

Returns

Task<MfaUnenrollResponse>

Update(string, UserAttributes, StatelessClientOptions)

Updates a User's attributes

public Task<User?> Update(string accessToken, UserAttributes attributes, StatelessClient.StatelessClientOptions options)

Parameters

accessToken string
attributes UserAttributes
options StatelessClient.StatelessClientOptions

Returns

Task<User>

UpdateUserById(string, StatelessClientOptions, string, AdminUserAttributes)

Update user by Id

public Task<User?> UpdateUserById(string serviceRoleToken, StatelessClient.StatelessClientOptions options, string userId, AdminUserAttributes userData)

Parameters

serviceRoleToken string

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

options StatelessClient.StatelessClientOptions
userId string
userData AdminUserAttributes

Returns

Task<User>

Verify(string, MfaVerifyParams, StatelessClientOptions)

Verifies a code against a challenge. The verification code is provided by the user by entering a code seen in their authenticator app.

public Task<MfaVerifyResponse?> Verify(string jwt, MfaVerifyParams mfaVerifyParams, StatelessClient.StatelessClientOptions options)

Parameters

jwt string
mfaVerifyParams MfaVerifyParams
options StatelessClient.StatelessClientOptions

Returns

Task<MfaVerifyResponse>

VerifyOTP(string, string, StatelessClientOptions, EmailOtpType)

Log in a user give a user supplied OTP received via email.

public Task<Session?> VerifyOTP(string email, string otpToken, StatelessClient.StatelessClientOptions options, Constants.EmailOtpType type = EmailOtpType.MagicLink)

Parameters

email string
otpToken string
options StatelessClient.StatelessClientOptions
type Constants.EmailOtpType

Returns

Task<Session>

VerifyOTP(string, string, StatelessClientOptions, MobileOtpType)

Log in a user given a User supplied OTP received via mobile.

public Task<Session?> VerifyOTP(string phone, string otpToken, StatelessClient.StatelessClientOptions options, Constants.MobileOtpType type = MobileOtpType.SMS)

Parameters

phone string

The user's phone number.

otpToken string

Token sent to the user's phone.

options StatelessClient.StatelessClientOptions
type Constants.MobileOtpType

Returns

Task<Session>

VerifyTokenHash(string, StatelessClientOptions, EmailOtpType)

Log in a user given the token hash used in an email confirmation link.

public Task<Session?> VerifyTokenHash(string tokenHash, StatelessClient.StatelessClientOptions options, Constants.EmailOtpType type = EmailOtpType.Email)

Parameters

tokenHash string
options StatelessClient.StatelessClientOptions
type Constants.EmailOtpType

Returns

Task<Session>