Class Api
The REST calls to the Gotrue API.
- Inheritance
-
Api
- Implements
-
IGettable
Headers
- Inherited Members
Constructors
Api(string, Dictionary<string, string>?)
Creates a new API client
Parameters
url
stringheaders
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.
Property Value
Headers
Headers to be sent with every request. These will be merged with any headers returned by GetHeaders.
Property Value
Methods
Challenge(string, MfaChallengeParams)
Parameters
jwt
stringmfaChallengeParams
MfaChallenge Params
Returns
CreateUser(string, AdminUserAttributes?)
Create a user
Parameters
jwt
stringA valid JWT. Must be a full-access API key (e.g. service_role key).
attributes
AdminUser Attributes Additional administrative details
Returns
DeleteFactor(string, MfaAdminDeleteFactorParams)
public Task<MfaAdminDeleteFactorResponse?> DeleteFactor(string jwt, MfaAdminDeleteFactorParams deleteFactorParams)
Parameters
jwt
stringdeleteFactorParams
MfaAdmin Delete Factor Params
Returns
DeleteUser(string, string)
Delete a user
Parameters
uid
stringThe user uid you want to remove.
jwt
stringA valid JWT. Must be a full-access API key (e.g. service_role key).
Returns
Enroll(string, MfaEnrollParams)
Parameters
jwt
stringmfaEnrollParams
MfaEnroll Params
Returns
ExchangeCodeForSession(string, string)
Log in an existing user via code from third-party provider.
Parameters
codeVerifier
stringGenerated verifier (probably from GetUrlForProvider)
authCode
stringThe received Auth Code Callback
Returns
GenerateLink(string, GenerateLinkOptions)
Generates email links and OTPs to be sent via a custom email provider.
Parameters
jwt
stringoptions
GenerateLink Options
Returns
GetUriForProvider(Provider, SignInOptions?)
public ProviderAuthState GetUriForProvider(Constants.Provider provider, SignInOptions? options = null)
Parameters
provider
Constants.Provideroptions
SignInOptions
Returns
GetUser(string)
Gets User Details
Parameters
jwt
string
Returns
GetUserById(string, string)
Get User details by Id
Parameters
Returns
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
stringjwt
stringthis token needs role 'supabase_admin' or 'service_role'
options
InviteUser ByEmail Options
Returns
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
stringUser's token
provider
Constants.ProviderProvider to Link
options
SignInOptions
Returns
ListFactors(string, MfaAdminListFactorsParams)
Parameters
jwt
stringlistFactorsParams
MfaAdmin List Factors Params
Returns
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
stringA valid JWT. Must be a full-access API key (e.g. service_role key).
filter
stringA string for example part of the email
sortBy
stringSnake 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
Reauthenticate(string)
Sends a re-authentication request, used for password changes.
Parameters
userJwt
stringThe user's auth token.
Returns
RefreshAccessToken(string, string)
Generates a new Session given a user's access token and refresh token.
Parameters
Returns
ResetPasswordForEmail(ResetPasswordForEmailOptions)
Sends a password reset request to an email address.
This Method supports the PKCE Flow
Parameters
options
ResetPassword For Email Options
Returns
ResetPasswordForEmail(string)
Sends a reset request to an email address.
Parameters
email
string
Returns
SendMagicLinkEmail(string, SignInOptions?)
Sends a magic login link to an email address.
Parameters
email
stringoptions
SignInOptions
Returns
SendMobileOTP(string)
Sends a mobile OTP via SMS. Will register the account if it doesn't already exist
Parameters
phone
stringphone The user's phone number WITH international prefix
Returns
Settings()
Calls the GoTrue server to get the settings (for example, if email auto confirmation is turned on)
Returns
SignInAnonymously(SignInAnonymouslyOptions?)
Creates a new anonymous user.
Parameters
options
SignInAnonymously Options
Returns
SignInWithEmail(string, string)
Logs in an existing user using their email address.
Parameters
Returns
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.ProviderA supported provider (Google, Apple, Azure, Facebook)
idToken
stringOIDC ID token issued by the specified provider. The
iss
claim in the ID token must match the supplied provider. Some ID tokens contain anat_hash
which require that you provide anaccess_token
value to be accepted properly. If the token contains anonce
claim you must supply the nonce used to obtain the ID token.accessToken
stringIf the ID token contains an
at_hash
claim, then the hash of this value is compared to the value in the ID token.nonce
stringIf the ID token contains a
nonce
claim, then the hash of this value is compared to the value in the ID token.captchaToken
stringVerification token received when the user completes the captcha on the site.
Returns
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.
Parameters
Returns
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.
Parameters
Returns
SignInWithPhone(string, string)
Logs in an existing user using their phone number and password.
Parameters
Returns
SignInWithSSO(Guid, SignInWithSSOOptions?)
Parameters
providerId
Guidoptions
SignInWith SSOOptions
Returns
SignInWithSSO(string, SignInWithSSOOptions?)
Parameters
domain
stringoptions
SignInWith SSOOptions
Returns
SignOut(string, SignOutScope)
Removes a logged-in session.
Parameters
jwt
stringscope
Constants.SignOut Scope
Returns
SignUpWithEmail(string, string, SignUpOptions?)
Signs a user up using an email address and password.
Parameters
email
stringpassword
stringoptions
SignUpOptions Optional Signup data.
Returns
SignUpWithPhone(string, string, SignUpOptions?)
Signs up a new user using their phone number and a password.The phone number of the user.
Parameters
phone
stringThe phone number of the user.
password
stringThe password of the user.
options
SignUpOptions Optional Signup data.
Returns
Unenroll(string, MfaUnenrollParams)
Parameters
jwt
stringmfaUnenrollParams
MfaUnenroll Params
Returns
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.
Parameters
token
stringUser's token
userIdentity
UserIdentity Identity to be unlinked
Returns
UpdateUser(string, UserAttributes)
Updates the User data
Parameters
jwt
stringattributes
UserAttributes
Returns
UpdateUserById(string, string, UserAttributes)
Update user by Id
Parameters
jwt
stringA valid JWT. Must be a full-access API key (e.g. service_role key).
userId
stringuserID
userData
UserAttributes User attributes e.g. email, password, etc.
Returns
Verify(string, MfaVerifyParams)
Parameters
jwt
stringmfaVerifyParams
MfaVerify Params
Returns
VerifyEmailOTP(string, string, EmailOtpType)
Send User supplied Email OTP to be verified
Parameters
email
stringThe user's email address
token
stringtoken that user was sent to their mobile phone
type
Constants.EmailOtp Type Type of verification, e.g. invite, recovery, etc.
Returns
VerifyMobileOTP(string, string, MobileOtpType)
Send User supplied Mobile OTP to be verified
Parameters
phone
stringThe user's phone number WITH international prefix
token
stringtoken that user was sent to their mobile phone
type
Constants.MobileOtp Type e.g. SMS or phone change
Returns
VerifyTokenHash(string, EmailOtpType)
Verify token hash used in an email confirmation link.
Parameters
tokenHash
stringThe token hash used in an email confirmation link
type
Constants.EmailOtp Type Type of verification, e.g. email.