# 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 mailbox
- Get the currently logged-in user information
- sign out
- Get the current user's custom data list
- Add custom data
- Delete custom data
- Bind social accounts
- Login with LDAP username
- Login with AD username
- Check password strength
- Get the user's organization
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
String email = "test@example.com";
String password = "123456";
User user = authenticationClient.registerByEmail(new RegisterByEmailInput(email, password)).execute();
# 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
String username = "test";
String password = "123456";
User user = authenticationClient.registerByUsername(new RegisterByUsernameInput(username, password)).execute();
# 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
String phone = "phone number";
String code = "1234";
String pasword = "123456"
User user = authenticationClient.registerByPhoneCode(new RegisterByPhoneCodeInput(phone, code).withPassword(password)).execute();
# 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
String phone = "phone number";
authenticationClient.sendSmsCode(phone).execute();
# 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
String email = "test@example.com";
String password = "123456";
User user = authenticationClient.loginByEmail(new LoginByEmailInput(email, password)).execute();
# 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
String username = "username";
String password = "123456";
User user = authenticationClient.loginByUsername(new LoginByUsernameInput(username, password)).execute();
# 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
String phone = "phone number";
String code = "1234";
User user = authenticationClient.loginByPhoneCode(new LoginByPhoneCodeInput(phone, code)).execute();
# 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
String phone = "phone number";
String password = "123456";
User user = authenticationClient.loginByPhonePassword(new LoginByPhonePasswordInput(phone, password)).execute();
# Check Token login status
AuthenticationClient().checkLoginStatus(token)
Check Token login status
# Parameters
token
<string> User's login credentials token
# Example
JwtTokenStatus status = authenticationClient.checkLoginStatus().execute();
# 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
authenticationClient.sendEmail("test@example.com", EmailScene.RESET_PASSWORD).execute();
# 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
String phone = "phone number";
String code = "1234";
String password = "123456";
authenticationClient.resetPasswordByPhoneCode(phone, code, password).execute();
# 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
String email = "test@example.com";
String code = "1234";
String password = "123456";
authenticationClient.resetPasswordByEmailCode(email, code, password).execute();
# 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
User user = authenticationClient.updateProfile(new UpdateUserInput().withNickname("nickname")).execute();
# 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
String oldPassword = "111111";
String newPassword = "123456";
User user = authenticationClient.updatePassword(newPassword, oldPassword).execute();
# 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
User user = authenticationClient.updatePhone("phone number", "1234").execute();
# 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
String newEmail = "new@example.com";
String emailCode = "1234"
User user = authenticationClient.updateEmail(newEmail, emailCode).execute();
# 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
RefreshToken token = authenticationClient.refreshToken().execute();
# 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
User user = authenticationClient.bindPhone("phone number", "1234").execute();
# Unbind mobile phone number
AuthenticationClient().unbindPhone()
User unbind mobile phone number
# Parameters
# Example
User user = authenticationClient.unbindPhone().execute();
# Unbind mailbox
AuthenticationClient().unbindEmail()
User unbind mailbox
# Example
User user = authenticationClient.unbindEmail().execute();
# Get the currently logged-in user information
AuthenticationClient().getCurrentUser()
Get the information of the currently logged in user
# Parameters
# Example
# sign out
AuthenticationClient().logout()
Log out, clear the user and token in localStorage
# Parameters
# Example
authenticationClient.logout().execute();
# Get the current user's custom data list
AuthenticationClient().listUdv()
Get the current user's custom data list
# Parameters
# Example
List<UserDefinedData> udv = authenticationClient.listUdv().execute();
# Add custom data
AuthenticationClient().setUdv(key, value)
Add custom data
# Parameters
key
<string> custom field keyvalue
<any> The value of the custom data, the value type must be consistent with the custom field type defined by the user pool.
# Example
authenticationClient.setUdv("key", "value").execute();
# Delete custom data
AuthenticationClient().removeUdv(key)
Delete custom data
# Parameters
key
<null> custom field key
# Example
authenticationClient.removeUdv("key").execute();
# Bind social accounts
AuthenticationClient().linkAccount(primaryUserToken, secondaryUserToken)
Bind a social account to a main account (mobile phone number, email account).
# Parameters
primaryUserToken
<string> Primary account TokensecondaryUserToken
<string> social account Token
# Example
String primaryUserToken = "test";
String secondaryUserToken = "test";
CommonMessage message = authenticationClient.linkAccount(primaryUserToken, secondaryUserToken).execute();
# Login with LDAP username
AuthenticationClient().loginByLdap(loginByLdapParam)
Login with LDAP username
# Parameters
username
<string> usernamepassword
<string> passwordoptions
<LoginByLdapParamOptions>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 side, be sure to set this parameter to the real IP of the end user.
# Example
String username = "test";
String password = "test";
LoginByLdapParam loginByLdapParam = new LoginByLdapParam(username, password);
User user = authenticationClient.loginByLdap(loginByLdapParam).execute();
# Login with AD username
AuthenticationClient().loginByAd(username, password)
Login with AD username
# Parameters
username
<string> usernamepassword
<string> password
# Example
String username = "test";
String password = "test";
User user = authenticationClient.loginByAd(username, password).execute();
# Check password strength
AuthenticationClient().checkPasswordStrength(password)
Check the password strength, please see: https://docs.authing.co/security/config-user-pool-password-level.html
# Parameters
password
<string> password
# Example
String password = "test";
CheckPasswordStrengthResult result = authenticationClient.checkPasswordStrength(password).execute();
# Get the user's organization
AuthenticationClient().listOrgs()
Get the user's organization and the complete path of the node he belongs to in this organization.
# Example
List<List<Org>> orgs = this.authenticationClient.listOrgs().execute();