# Core Authentication Module
- Core Authentication Module
- Register with Email
- Register with username
- Use mobile phone number to register
- Send SMS verification code
- Login with email
- Login with username
- Login with mobile phone number verification code
- Login with mobile phone number and password
- Check Token login status
- send email
- Reset password via SMS verification code
- Reset password via email verification code
- Modify user information
- Update user password
- Update user phone number
- Update user mailbox
- Refresh the current user's token
- Bind mobile phone number
- Unbind mobile phone number
- Unbind mobile phone number
- Get the currently logged-in user information
This module contains methods such as registering and logging in, resetting the mobile phone number, email, and modifying account information. It is requested as your end user (End User), and is suitable for use in situations where the identity of the user needs to be verified.
# Register with Email
AuthenticationClient().registerByEmail(email, password, profile, options)
Use email to register. This interface does not require the user to verify the email. After the user registers, the emailVerified field will be false. If you want users with unauthenticated mailboxes to be unable to log in, you can use the pipeline to intercept such requests.
# Parameters
email
<string> mailboxpassword
<string> passwordprofile
<RegisterProfile> user profileoptions
<Object>options.forceLogin
<boolean> Whether to go through the complete login, it will trigger the pipeline function before and after the login and the login event webhook, and the cumulative login times of the user will be increased by 1. The default is false.options.generateToken
<boolean> Whether to generate a token for the user, it will not trigger the complete process after login, and the user's cumulative login times will not increase by 1. The default is false.options.clientIp
<string> The real IP of the client. If you call this interface on the server, you must set this parameter to the real IP of the end user.
# Example
var email = "test@example.com";
var password = "123456";
var user = await authenticationClient.RegisterByEmail(email, password);
Console.WriteLine(user.Email);
# Register with username
AuthenticationClient().registerByUsername(username, password, profile, options)
Register with username
# Parameters
username
<string> usernamepassword
<string> passwordprofile
<RegisterProfile> user profileoptions
<Object>options.forceLogin
<boolean> Whether to go through the complete login, it will trigger the pipeline function before and after the login and the login event webhook, and the cumulative login times of the user will be increased by 1. The default is false.options.generateToken
<boolean> Whether to generate a token for the user, it will not trigger the complete process after login, and the user's cumulative login times will not increase by 1. The default is false.options.clientIp
<string> The real IP of the client. If you call this interface on the server, you must set this parameter to the real IP of the end user.
# Example
var username = "test";
var password = "123456";
var user = await authenticationClient.RegisterByUsername(email, password);
Console.WriteLine(user.Username);
# Use mobile phone number to register
AuthenticationClient().registerByPhoneCode(phone, code, password, profile, options)
Register with your mobile phone number, you can set the initial password of the account at the same time. Please see sendSmsCode for the interface to send SMS
# Parameters
phone
<string> phone numbercode
<string> SMS verification codepassword
<string> initial passwordprofile
<RegisterProfile> user profileoptions
<Object>options.forceLogin
<boolean> Whether to go through the complete login, it will trigger the pipeline function before and after the login and the login event webhook, and the cumulative login times of the user will be increased by 1. The default is false.options.generateToken
<boolean> Whether to generate a token for the user, it will not trigger the complete process after login, and the user's cumulative login times will not increase by 1. The default is false.options.clientIp
<string> The real IP of the client. If you call this interface on the server, you must set this parameter to the real IP of the end user.
# Example
var phone = "phone number";
var code = "1234";
var password = "123456";
var user = await authenticationClient.RegisterByPhoneCode(phone, code, password);
Console.WriteLine(user.Phone);
# Send SMS verification code
AuthenticationClient().sendSmsCode(phone)
Send SMS verification code, the validity time of the SMS verification code is 60 s.
# Parameters
phone
<string>
# Example
var phone = "phone number";
await authenticationClient.SendSmsCode(phone);
# Login with email
AuthenticationClient().loginByEmail(email, password, options)
Use email to log in. By default, the interface does not restrict logins to unverified emails. If you want users with unverified emails to not log in, you can use the pipeline to intercept such requests.
If your user pool is configured with login failure detection, the user will be asked to enter a graphic verification code (code 2000) when the login fails multiple times under the same IP.
# Parameters
email
<string> mailboxpassword
<string> passwordoptions
<Object>options.autoRegister
<boolean> Whether to register automatically. If it detects that the user does not exist, an account will be automatically created based on the login account password.options.captchaCode
<string> Graphic verification codeoptions.clientIp
<string> The real IP of the client. If you call this interface on the server, you must set this parameter to the real IP of the end user.
# Example
var email = "test@example.com";
var password = "123456";
var user = await authenticationClient.LoginByEmail(email, password);
Console.WriteLine(user.Email);
# Login with username
AuthenticationClient().loginByUsername(username, password, options)
Log in with username.
If your user pool is configured with login failure detection, the user will be asked to enter a graphic verification code (code 2000) when the login fails multiple times under the same IP.
# Parameters
username
<string> usernamepassword
<string> passwordoptions
<Object>options.autoRegister
<boolean> Whether to register automatically. If it detects that the user does not exist, an account will be automatically created based on the login account password.options.captchaCode
<string> Graphic verification codeoptions.clientIp
<string> The real IP of the client. If you call this interface on the server, you must set this parameter to the real IP of the end user.
# Example
var username = "username";
var password = "123456";
var user = await authenticationClient.LoginByUsername(username, password);
Console.WriteLine(user.Username);
# Login with mobile phone number verification code
AuthenticationClient().loginByPhoneCode(phone, code)
Use the mobile phone number verification code to log in.
# Parameters
phone
<string> phone numbercode
<string> SMS verification codeoptions.clientIp
<string> The real IP of the client. If you call this interface on the server, you must set this parameter to the real IP of the end user.
# Example
var phone = "phone number";
var code = "1234";
var user = await authenticationClient.LoginByPhoneCode(phone, code);
Console.WriteLine(user.Phone);
# Login with mobile phone number and password
AuthenticationClient().loginByPhonePassword(phone, password, options)
Use your phone number and password to log in.
# Parameters
phone
<string> phone numberpassword
<string> passwordoptions
<Object>options.captchaCode
<string> Graphic verification codeoptions.clientIp
<string> The real IP of the client. If you call this interface on the server, you must set this parameter to the real IP of the end user.
# Example
var phone = "phone number";
var password = "123456";
var user = await authenticationClient.LoginByPhonePassword(phone, password);
Console.WriteLine(user.Phone);
# Check Token login status
AuthenticationClient().checkLoginStatus(token)
Check Token login status
# Parameters
token
<string> user's login credentials token
# Example
Console.WriteLine(status.code == 200);
# send email
AuthenticationClient().sendEmail(email, scene)
Send mail
# Parameters
email
<string> mailboxscene
<EmailScene> Sending scene, optional values are RESET_PASSWORD (send reset password email, the email contains the verification code), VerifyEmail (send the email to verify the email), ChangeEmail (send the modified email, the email contains Verification code)
# Example
using Authing.ApiClient.Types;
var message = await authenticationClient.SendEmail("test@example.com", EmailScene.RESET_PASSWORD);
# Reset password via SMS verification code
AuthenticationClient().resetPasswordByPhoneCode(phone, code, newPassword)
To reset the password by SMS verification code, you need to call the sendSmsCode interface to send the reset password email.
# Parameters
phone
<string> phone numbercode
<string> verification codenewPassword
<string> new password
# Example
var phone = "phone number";
var code = "1234";
var password = "123456";
var message = await authenticationClient.ResetPasswordByPhoneCode(phone, code, password);
# Reset password via email verification code
AuthenticationClient().resetPasswordByEmailCode(phone, code, newPassword)
To reset the password through the email verification code, you need to call the sendEmail interface to send the reset password email.
# Parameters
phone
<string> phone numbercode
<string> verification codenewPassword
<string> new password
# Example
var email = "test@example.com";
var code = "1234";
var password = "123456";
var message = await authenticationClient.ResetPasswordByEmailCode(email, code, password);
# Modify user information
AuthenticationClient().updateProfile(updates)
Modify user information. This interface cannot be used to modify the phone number, email address, and password. If necessary, please call the updatePhone, updateEmail, and updatePassword interfaces.
# Parameters
updates
<UpdateUserInput> modified user profileupdates.username
<string> usernameupdates.nickname
<string> nicknameupdates.photo
<string> Avatarupdates.company
<string> companyupdates.browser
<string> browserupdates.device
<string> deviceupdates.lastIP
<string> Last logged in IPupdates.name
<string> Nameupdates.givenName
<string> Given Nameupdates.familyName
<string> Family Nameupdates.middleName
<string> Middle Nameupdates.profile
<string> Profile Urlupdates.preferredUsername
<string> Preferred Nameupdates.website
<string> personal websiteupdates.gender
<string> gender, M stands for male, W stands for female, and U stands for unknown.updates.birthdate
<string> birthdayupdates.zoneinfo
<string> time zoneupdates.locale
<string> languageupdates.address
<string> addressupdates.streetAddress
<string> street addressupdates.locality
<string>updates.region
<string> regionupdates.postalCode
<string> Zip codeupdates.city
<string> cityupdates.province
<string> provinceupdates.country
<string> country
# Example
var user = await authenticationClient.UpdateProfile(new UpdateUserInput()
{
Nickname = nickname,
});
# Update user password
AuthenticationClient().updatePassword(newPassword, oldPassword)
Update user password
# Parameters
newPassword
<string> new passwordoldPassword
<string> Old password, if the user has not set a password, you can leave it blank.
# Example
var oldPassword = "111111";
var newPassword = "123456";
await authenticationClient.UpdatePassword(newPassword, oldPassword);
# Update user phone number
AuthenticationClient().updatePhone(phone, phoneCode, oldPhone, oldPhoneCode)
Update the user's mobile phone number. Just like modifying the mailbox, by default, if the user has already bound a mobile phone number, the original mobile phone number (the mobile phone number bound to the current account) and the current mailbox (the mobile phone number to be bound) need to be verified at the same time. In other words, the mobile phone number currently bound to user A is 15888888888, and if you want to change it to 15899999999, you need to verify both mobile phone numbers. Developers can also choose not to turn on "Verify original phone number", which can be turned off in the security information module under the settings directory of the Authing console. To bind a mobile phone number for the first time, please use the bindPhone interface.
# Parameters
phone
<string> new phone numberphoneCode
<string> The verification code of the new phone numberoldPhone
<string> old phone numberoldPhoneCode
<string> The verification code of the old phone number
# Example
await authenticationClient.UpdatePhone("phone number", "1234");
# Update user mailbox
AuthenticationClient().updateEmail(email, emailCode, oldEmail, oldEmailCode)
If the user has already bound the mailbox, by default, the original mailbox (the mailbox bound to the current account) and the current mailbox (the mailbox to be bound) need to be verified at the same time. In other words, the currently bound mailbox of user A is 123456@qq.com, and wants to modify it to 1234567@qq.com, then both mailboxes need to be verified at the same time. Developers can also choose not to turn on "Verify original mailbox", which can be turned off in the security information module under the settings directory of the Authing console. For the first time to bind a mobile phone number, please use the bindEmail interface.
# Parameters
email
<string> new mailboxemailCode
<string> The verification code of the new mailboxoldEmail
<string> old emailoldEmailCode
<string> The verification code of the old email
# Example
var newEmail = "new@example.com";
var emailCode = "1234"
await authenticationClient.UpdateEmail(newEmail, emailCode);
# Refresh the current user's token
AuthenticationClient().refreshToken()
Refresh the token of the current user, and call this interface to require login first.
# Parameters
# Example
var refreshToken = await authenticationClient.RefreshToken();
Console.WriteLine(refreshToken.Token);
# Bind mobile phone number
AuthenticationClient().bindPhone(phone, phoneCode)
The user binds the mobile phone number for the first time. If you need to modify the mobile phone number, please use the updatePhone interface.
# Parameters
phone
<string>phoneCode
<string>
# Example
var phone = "phone number";
var phoneCode = "1234"
await authenticationClient.BindPhone(phone, phoneCode);
# Unbind mobile phone number
AuthenticationClient().unbindPhone()
User unbind mobile phone number
# Parameters
# Example
await authenticationClient.UnbindPhone();
# Unbind mobile phone number
AuthenticationClient().unbindPhone()
User unbind mobile phone number
# Parameters
# Example
await authenticationClient.UnbindPhone();