applyPublicKey
POST /ams/api/v1/customer/applyPublicKey
Use this API to apply a public key and salt, which is used to encrypt a plaintext password.
Note:
- The encryption algorithm is RSA.
- The public key applied each time can only be used to encrypt a plaintext password once. So, the request with a ciphertext field needs to re-apply for the public key before each request.
Structure
A message consists of a header and body. The following sections are focused on the body structure. For the header structure, see:
Note: Set the data type of each field (except array) as String. This means that you must use double quotation marks (" ") to enclose the field value. Examples:
- If the data type of a field is Integer and its value is 20, set it as "20".
- If the data type of a field is Boolean and its value is
true
, set it as "true".
Request parameters
Field | Data type | Required | Description | Examples |
customerId | String | No | The unique ID that is used to identify a buyer. This field is composed of 16 digits and begins with 21. More information about this field:
| "2162878776333" |
Response parameters
Field | Data type | Required | Description | Examples |
result | Yes | The request result, which contains information such as status and error codes. | / | |
publicKeyInfo | No | The public key for encrypting a plaintext password. See PublicKeyInfo for details. | / |
Result processing logic
In the response, the result.resultStatus field indicates the result of the applyPublicKey request. The following table describes each result status:
Resultstatus | Description |
S | The applyPublicKey request is accepted successfully. The corresponding result.resultCode is
|
U | The status of the public key application is unknown. The corresponding result.resultCode is |
F | The applyPublicKey request failed. The corresponding result.resultCode and result.resultMessage may vary based on different situations. For details, see the following Error codes section. |
Error codes
Result code | Result status | Result message | Further action |
SUCCESS | S | Success | / |
USER_STATUS_ABNORMAL | F | The user status is abnormal. | Contact the digital wallet to check the user status. |
PARAM_ILLEGAL | F | Illegal parameters exist. For example, a non-numeric input, or an invalid date. | Check and verify whether the request fields, including the header fields and body fields, are correct and valid. For details on the fields of each API, see the specific API Structure section. |
PROCESS_FAIL | F | A general business failure occurred. Don't retry. | Human intervention is usually needed. It is recommended that you contact the technical support team to troubleshoot the issue. |
UNKNOWN_EXCEPTION | U | An API call is failed, which is caused by unknown reasons. | Call the interface again to resolve the issue. If the issue persists, contact Alipay Technical Support. |
Samples
Request
The merchant sends a request to apply a public key.
{
"customerId": "2188000000000000000",
}
Response
DWS returns the request result to the merchant.
{
"publicKeyInfo": {
"uniqueId": "s8NeKdTshiXVAPXzBRTIQigKh4PbnIiS",
"salt": "IRfe92wH04sh",
"publicKey": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxn/zCJXInbQiQpJpnV6KmK/Cci3sXhymx2vgs+s/tss9ny6pZNmrO9bG/lYUEm69+L/Mfq/mWxBHee3BGCSvtACYrYjWE5jKP3X91RcxFfYDH8dwTfMBNFatRINm3oHpdWDqOdX5FPtHNNX69prMC+/2IrdIvN/ui1JWXhqgk5Z9h8CJuf6hrEW0fjJLeeN9MHmPi/uWRXLHQUHjJb3a9oaHEur/6jDxpHLo2IGldlHjy9UHAZAIcpNMhw+ufKbA4IzS+gATE0jORLTOU2x+v0FfxnnSCbiQ1LNvaDFrwSQ2ttf9FAdKl2AW5g5cFELxMZ5TYvKMOkkIwhcclw1QvwIDAQAB"
},
"result":{
"resultCode":"SUCCESS",
"resultMessage":"success.",
"resultStatus":"S"
}
}