Class StatelessClient
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
stringmfaChallengeParams
MfaChallengeParamsoptions
StatelessClient.StatelessClientOptions
Returns
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
stringmfaChallengeAndVerifyParams
MfaChallengeAndVerifyParamsoptions
StatelessClient.StatelessClientOptions
Returns
CreateUser(string, StatelessClientOptions, AdminUserAttributes)
Create a user
public Task<User?> CreateUser(string serviceRoleToken, StatelessClient.StatelessClientOptions options, AdminUserAttributes attributes)
Parameters
serviceRoleToken
stringA valid JWT. Must be a full-access API key (e.g. service_role key).
options
StatelessClient.StatelessClientOptionsattributes
AdminUserAttributes
Returns
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
stringA valid JWT. Must be a full-access API key (e.g. service_role key).
options
StatelessClient.StatelessClientOptionsemail
stringpassword
stringattributes
AdminUserAttributes
Returns
DeleteUser(string, string, StatelessClientOptions)
Deletes a User.
public Task<bool> DeleteUser(string uid, string serviceRoleToken, StatelessClient.StatelessClientOptions options)
Parameters
uid
stringserviceRoleToken
stringthis token needs role 'supabase_admin' or 'service_role'
options
StatelessClient.StatelessClientOptions
Returns
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
stringmfaEnrollParams
MfaEnrollParamsoptions
StatelessClient.StatelessClientOptions
Returns
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
stringauthCode
stringoptions
StatelessClient.StatelessClientOptions
Returns
GetApi(StatelessClientOptions)
Initialize/retrieve the underlying API for this client
public IGotrueApi<User, Session> GetApi(StatelessClient.StatelessClientOptions options)
Parameters
Returns
GetAuthenticatorAssuranceLevel(string, StatelessClientOptions)
Returns the Authenticator Assurance Level (AAL) for the active session.
aal1
(ornull
) 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
stringoptions
StatelessClient.StatelessClientOptions
Returns
GetSessionFromUrl(Uri, StatelessClientOptions)
public Task<Session?> GetSessionFromUrl(Uri uri, StatelessClient.StatelessClientOptions options)
Parameters
uri
Urioptions
StatelessClient.StatelessClientOptions
Returns
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
stringA valid JWT. Must be a JWT that originates from a user.
options
StatelessClient.StatelessClientOptions
Returns
GetUserById(string, StatelessClientOptions, string)
Get User details by Id
public Task<User?> GetUserById(string serviceRoleToken, StatelessClient.StatelessClientOptions options, string userId)
Parameters
serviceRoleToken
stringA valid JWT. Must be a full-access API key (e.g. service_role key).
options
StatelessClient.StatelessClientOptionsuserId
string
Returns
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
stringserviceRoleToken
stringthis token needs role 'supabase_admin' or 'service_role'
options
StatelessClient.StatelessClientOptionsinvitationOptions
InviteUserByEmailOptions
Returns
ListFactors(string, StatelessClientOptions)
Returns the list of MFA factors enabled for this user
public Task<MfaListFactorsResponse?> ListFactors(string jwt, StatelessClient.StatelessClientOptions options)
Parameters
jwt
stringoptions
StatelessClient.StatelessClientOptions
Returns
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
stringA valid JWT. Must be a full-access API key (e.g. service_role key).
options
StatelessClient.StatelessClientOptionsfilter
stringA string for example part of the email
sortBy
stringSnake case string of the given key, currently only created_at is supported
sortOrder
Constants.SortOrderasc or desc, if null desc is used
page
int?page to show for pagination
perPage
int?items per page for pagination
Returns
RefreshToken(string, string, StatelessClientOptions)
Refreshes a Token
public Task<Session?> RefreshToken(string accessToken, string refreshToken, StatelessClient.StatelessClientOptions options)
Parameters
accessToken
stringrefreshToken
stringoptions
StatelessClient.StatelessClientOptions
Returns
ResetPasswordForEmail(string, StatelessClientOptions)
Sends a reset request to an email address.
public Task<bool> ResetPasswordForEmail(string email, StatelessClient.StatelessClientOptions options)
Parameters
email
stringoptions
StatelessClient.StatelessClientOptions
Returns
Exceptions
SendMagicLink(string, StatelessClientOptions, SignInOptions?)
Sends a Magic email login link to the specified email.
public Task<bool> SendMagicLink(string email, StatelessClient.StatelessClientOptions options, SignInOptions? signInOptions = null)
Parameters
email
stringoptions
StatelessClient.StatelessClientOptionssignInOptions
SignInOptions
Returns
Settings(StatelessClientOptions)
Retrieve the current settings for the Gotrue instance.
public Task<Settings?> Settings(StatelessClient.StatelessClientOptions options)
Parameters
Returns
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.Provideroptions
StatelessClient.StatelessClientOptionssignInOptions
SignInOptions
Returns
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.SignInTypeType of Credentials being passed
identifierOrToken
stringAn email, phone, or RefreshToken
password
stringPassword to account (optional if
RefreshToken
)options
StatelessClient.StatelessClientOptions
Returns
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
stringoptions
StatelessClient.StatelessClientOptionssignInOptions
SignInOptions
Returns
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
stringpassword
stringoptions
StatelessClient.StatelessClientOptions
Returns
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
stringoptions
StatelessClient.StatelessClientOptions
Returns
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.SignUpTypeType of signup
identifier
stringPhone or Email
password
stringoptions
StatelessClient.StatelessClientOptionssignUpOptions
SignUpOptionsObject containing redirectTo and optional user metadata (data)
Returns
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
stringpassword
stringoptions
StatelessClient.StatelessClientOptionssignUpOptions
SignUpOptionsObject containing redirectTo and optional user metadata (data)
Returns
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
stringmfaUnenrollParams
MfaUnenrollParamsoptions
StatelessClient.StatelessClientOptions
Returns
Update(string, UserAttributes, StatelessClientOptions)
Updates a User's attributes
public Task<User?> Update(string accessToken, UserAttributes attributes, StatelessClient.StatelessClientOptions options)
Parameters
accessToken
stringattributes
UserAttributesoptions
StatelessClient.StatelessClientOptions
Returns
UpdateUserById(string, StatelessClientOptions, string, AdminUserAttributes)
Update user by Id
public Task<User?> UpdateUserById(string serviceRoleToken, StatelessClient.StatelessClientOptions options, string userId, AdminUserAttributes userData)
Parameters
serviceRoleToken
stringA valid JWT. Must be a full-access API key (e.g. service_role key).
options
StatelessClient.StatelessClientOptionsuserId
stringuserData
AdminUserAttributes
Returns
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
stringmfaVerifyParams
MfaVerifyParamsoptions
StatelessClient.StatelessClientOptions
Returns
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
stringotpToken
stringoptions
StatelessClient.StatelessClientOptionstype
Constants.EmailOtpType
Returns
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
stringThe user's phone number.
otpToken
stringToken sent to the user's phone.
options
StatelessClient.StatelessClientOptionstype
Constants.MobileOtpType
Returns
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
stringoptions
StatelessClient.StatelessClientOptionstype
Constants.EmailOtpType