- Development Integration
- /
- SDK
- /
- Java
- /
User authentication module
- /
User information
- /
- Forgot password
¶ Forgot password
Update time: 2025-07-23 07:34:21
This document is automatically generated based on https://github.com/authing/authing-docs-factory based on https://api-explorer.genauth.ai V3 API, and is consistent with API parameters and return results. If the description of this document is incorrect, please refer to V3 API.
This endpoint is used to reset the password by mobile phone verification code or email verification code after the user forgets the password. This interface requires the provision of a temporary credential passwordResetToken for resetting the password, which needs to be obtained through the Initiate a Forgot Password Request interface.
¶ Method Name
AuthenticationClient.resetPassword
¶ Request Parameters
| Name | Type | Is it required | Default Value | Description | Example Value |
|---|---|---|---|---|---|
| password | string | Yes | - | Password | |
| passwordResetToken | string | Yes | - | Token for resetting password | |
| passwordEncryptType | string | No | none | Password encryption type, supports encryption using RSA256 and SM2 algorithms. The default is none, no encryption.- none: Do not encrypt the password and transmit it in plain text.- rsa: Use the RSA256 algorithm to encrypt the password. You need to use the RSA public key of the GenAuth service for encryption. Please read the Introduction section to learn how to obtain the RSA256 public key of the GenAuth service.- sm2: Use the National Secret SM2 Algorithm (opens new window) to encrypt the password. You need to use the SM2 public key of the GenAuth service for encryption. Please read the Introduction section to learn how to obtain the SM2 public key of the GenAuth service. | none |
¶ Sample Code
package test.authentication;
import cn.authing.sdk.java.client.AuthenticationClient;
import cn.authing.sdk.java.dto.IsSuccessRespDto;
import cn.authing.sdk.java.dto.ResetPasswordDto;
import cn.authing.sdk.java.model.AuthenticationClientOptions;
import cn.authing.sdk.java.util.JsonUtils;
public class ResetPasswordTest {
// Need to be replaced with your GenAuth App ID
private static final String APP_ID = "AUTHING_APP_ID";
// Need to be replaced with your GenAuth App Secret
private static final String APP_SECRET = "AUTHING_APP_SECRET";
// Need to be replaced with your GenAuth App Host
private static final String APP_HOST = "AUTHING_APP_HOST";
public static void main(String[] args) throws Throwable {
AuthenticationClientOptions clientOptions = new AuthenticationClientOptions();
clientOptions.setAppId(APP_ID);
clientOptions.setAppSecret(APP_SECRET);
clientOptions.setAppHost(APP_HOST);
AuthenticationClient client = new AuthenticationClient(clientOptions);
ResetPasswordDto reqDto = new ResetPasswordDto();
reqDto.setPassword("123");
// This interface needs to provide a temporary credential passwordResetToken for resetting the password. This parameter needs to be obtained by initiating the forgotten password request interface. reqDto.setPasswordResetToken("xxx");
IsSuccessRespDto response = client.resetPassword(reqDto);
System.out.println(JsonUtils.serialize(response));
}
}
¶ Request Response
Type: IsSuccessRespDto
| Name | Type | Description |
|---|---|---|
| statusCode | number | Business status code. You can use this status code to determine whether the operation is successful. 200 means success. |
| message | string | Description |
| apiCode | number | Segment error code, through which you can get the specific error type (successful request does not return). For a detailed list of error codes, see: API Code List (opens new window) |
| requestId | string | Request ID. Returned when the request fails. |
| data | IsSuccessDto | Whether the operation is successful |
Example Results:
{
"statusCode": 200,
"message": "Operation successful",
"requestId": "934108e5-9fbf-4d24-8da1-c330328abd6c",
"data": {
"success": true
}
}
¶ Data Structure
¶ IsSuccessDto
| Name | Type | Is it required | Description | Example Value |
|---|---|---|---|---|
| success | boolean | Yes | Whether the operation is successful | true |
