Your app server can call this API to check the validity of a device token, ensuring that the device is a real Huawei device.
After obtaining a device token, you can call this API to check the validity of the device token, ensuring that the device is a real Huawei device.
Differences between this capability and device attestation:
| Open Capability | Description |
|---|---|
| Device token verification | This capability is a lightweight implementation of device attestation, which has simple requirements on integration. This capability cannot defend against replay attacks. In addition, it requires interaction with the Device Security server in each verification, which will lead to service processing delay. |
| Device attestation | In this capability, a public/private key pair is created in the trusted execution environment (TEE) on the device side, and the public key is attested and stored on the app server. This requires you to store the attested public key on the app server and maintain the lifecycle of the public key, posing high requirements on integration. This capability can defend against replay attacks. Subsequent service requests do not need to interact with the device attestation server, which will not cause significant service processing delay. |
You are advised to choose a suitable capability based on your actual security requirements and service scenarios.
Data format: Request header: Content-Type: application/json;charset=utf-8
Response: Content-Type: application/json;charset=utf-8
Request Header
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| Content-Type | No | String | Content type. The value is application/json;charset=utf-8. |
| Authorization | Yes | String | Access token generated from a service account. |
| bundleName | Yes | String | Your app package name. |
The value of Authorization is Bearer followed by a space character and then the obtained authentication information. For details about how to generate a token, see Sample Code
Request Body
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| deviceToken | Yes | String | Temporary device token obtained by the client via getDeviceToken. |
| transactionId | No | String | Unique transaction ID of an app service, which is used to associate the service context. |
| timestamp | Yes | Long | UTC time on the app server, in milliseconds. |
When constructing a message body, you need to wrap a data structure around the message body. For details, see the following API call example.
post /api/rms/v1/deviceVerify/checkDeviceToken HTTP/1.1
Host: xxx
Authorization: Bearer eyJr*****OiIx---****.eyJh*****iJodHR--***.QRod*****4Gp---****
bundleName: com.huawei.xxx
Content-Type: application/json;charset=utf-8
{"data":{ "deviceToken":"xxx", "transactionId":"xxx", "timestamp":1704038400}} Response Body
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| bundleName | No | String | Package name obtained from a token for your verification. |
| errorCodes | Yes | String | Error code. |
HTTP/1.1 200 OK
Content-Type: application/json;charset=utf-8
{"bundleName":"xxx","errorCodes":"OK"} For details about the error codes, see REST API Error Codes.
| Error Code | Description |
|---|---|
| OK | The request is successfully processed. |
| InvalidDeviceToken | The device token is missing or invalid. |
| DeviceTokenExpired | The device token has expired. |
| InvalidTimeStamp | The timestamp is missing or invalid. |
| InternalServerError | Internal server error. |
| InvalidBundleName | The package name is missing or invalid. |