Interface IGotrueStatelessClient<TUser, TSession>
- Namespace
- Supabase.Gotrue.Interfaces
- Assembly
- Supabase.Gotrue.dll
A Stateless Gotrue Client
public interface IGotrueStatelessClient<TUser, TSession> where TUser : User where TSession : Session
Type Parameters
TUser
TSession
Examples
var options = new StatelessClientOptions { Url = "https://mygotrueurl.com" }; var user = await client.SignIn("user@email.com", "fancyPassword", options);
Methods
Challenge(string, MfaChallengeParams, StatelessClientOptions)
Prepares a challenge used to verify that a user has access to a MFA factor.
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.
Task<MfaVerifyResponse?> ChallengeAndVerify(string jwt, MfaChallengeAndVerifyParams mfaChallengeAndVerifyParams, StatelessClient.StatelessClientOptions options)
Parameters
jwt
stringmfaChallengeAndVerifyParams
MfaChallengeAndVerifyParamsoptions
StatelessClient.StatelessClientOptions
Returns
CreateUser(string, StatelessClientOptions, AdminUserAttributes)
Create a user
Task<TUser?> 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
- Task<TUser>
CreateUser(string, StatelessClientOptions, string, string, AdminUserAttributes?)
Create a user
Task<TUser?> 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
- Task<TUser>
DeleteUser(string, string, StatelessClientOptions)
Deletes a User.
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
.
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.
Task<TSession?> ExchangeCodeForSession(string codeVerifier, string authCode, StatelessClient.StatelessClientOptions options)
Parameters
codeVerifier
stringauthCode
stringoptions
StatelessClient.StatelessClientOptions
Returns
- Task<TSession>
GetApi(StatelessClientOptions)
Initialize/retrieve the underlying API for this client
IGotrueApi<TUser, TSession> GetApi(StatelessClient.StatelessClientOptions options)
Parameters
Returns
- IGotrueApi<TUser, TSession>
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.
Task<MfaGetAuthenticatorAssuranceLevelResponse?> GetAuthenticatorAssuranceLevel(string jwt, StatelessClient.StatelessClientOptions options)
Parameters
jwt
stringoptions
StatelessClient.StatelessClientOptions
Returns
GetSessionFromUrl(Uri, StatelessClientOptions)
Task<TSession?> GetSessionFromUrl(Uri uri, StatelessClient.StatelessClientOptions options)
Parameters
uri
Urioptions
StatelessClient.StatelessClientOptions
Returns
- Task<TSession>
GetUser(string, StatelessClientOptions)
Get User details by JWT. Can be used to validate a JWT.
Task<TUser?> GetUser(string serviceRoleToken, StatelessClient.StatelessClientOptions options)
Parameters
serviceRoleToken
stringA valid JWT. Must be a JWT that originates from a user.
options
StatelessClient.StatelessClientOptions
Returns
- Task<TUser>
GetUserById(string, StatelessClientOptions, string)
Get User details by Id
Task<TUser?> 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
- Task<TUser>
InviteUserByEmail(string, string, StatelessClientOptions, InviteUserByEmailOptions?)
Sends an invite email link to the specified email.
Task<bool> InviteUserByEmail(string email, string serviceRoleToken, StatelessClient.StatelessClientOptions options, InviteUserByEmailOptions? inviteOptions = null)
Parameters
email
stringserviceRoleToken
stringthis token needs role 'supabase_admin' or 'service_role'
options
StatelessClient.StatelessClientOptionsinviteOptions
InviteUserByEmailOptions
Returns
ListFactors(string, StatelessClientOptions)
Returns the list of MFA factors enabled for this user
Task<MfaListFactorsResponse?> ListFactors(string jwt, StatelessClient.StatelessClientOptions options)
Parameters
jwt
stringoptions
StatelessClient.StatelessClientOptions
Returns
ListUsers(string, StatelessClientOptions, string?, string?, SortOrder, int?, int?)
Lists users
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
Task<TSession?> RefreshToken(string accessToken, string refreshToken, StatelessClient.StatelessClientOptions options)
Parameters
accessToken
stringrefreshToken
stringoptions
StatelessClient.StatelessClientOptions
Returns
- Task<TSession>
ResetPasswordForEmail(string, StatelessClientOptions)
Sends a reset request to an email address.
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.
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.
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.
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.
Task<TSession?> 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
- Task<TSession>
SignIn(string, StatelessClientOptions, SignInOptions?)
Sends a Magic email login link to the specified email.
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.
Task<TSession?> SignIn(string email, string password, StatelessClient.StatelessClientOptions options)
Parameters
email
stringpassword
stringoptions
StatelessClient.StatelessClientOptions
Returns
- Task<TSession>
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.
Task<bool> SignOut(string accessToken, StatelessClient.StatelessClientOptions options)
Parameters
accessToken
stringoptions
StatelessClient.StatelessClientOptions
Returns
SignUp(SignUpType, string, string, StatelessClientOptions, SignUpOptions?)
Signs up a user
Task<TSession?> 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
- Task<TSession>
SignUp(string, string, StatelessClientOptions, SignUpOptions?)
Signs up a user by email address
Task<TSession?> 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
- Task<TSession>
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.
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
Task<TUser?> Update(string accessToken, UserAttributes attributes, StatelessClient.StatelessClientOptions options)
Parameters
accessToken
stringattributes
UserAttributesoptions
StatelessClient.StatelessClientOptions
Returns
- Task<TUser>
UpdateUserById(string, StatelessClientOptions, string, AdminUserAttributes)
Update user by Id
Task<TUser?> 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
- Task<TUser>
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.
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.
Task<TSession?> VerifyOTP(string email, string otpToken, StatelessClient.StatelessClientOptions options, Constants.EmailOtpType type = EmailOtpType.MagicLink)
Parameters
email
stringotpToken
stringoptions
StatelessClient.StatelessClientOptionstype
Constants.EmailOtpType
Returns
- Task<TSession>
VerifyOTP(string, string, StatelessClientOptions, MobileOtpType)
Log in a user given a User supplied OTP received via mobile.
Task<TSession?> 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
- Task<TSession>
VerifyTokenHash(string, StatelessClientOptions, EmailOtpType)
Log in a user given the token hash used in an email confirmation link.
Task<TSession?> VerifyTokenHash(string tokenHash, StatelessClient.StatelessClientOptions options, Constants.EmailOtpType type = EmailOtpType.Email)
Parameters
tokenHash
stringoptions
StatelessClient.StatelessClientOptionstype
Constants.EmailOtpType
Returns
- Task<TSession>