Authentication
Requests for calling an API can be authenticated using either of the following methods:
- Token-based authentication: Requests are authenticated using a token.
- Authentication using AK/SK: Requests are encrypted using AK/SK.
Authentication Using Tokens
The validity period of a token is 24 hours. When using a token for authentication, cache it to prevent frequent calling of the API used to obtain a user token.
A token specifies temporary permissions in a computer system. During API authentication using a token, the token is added to request headers to get permissions for calling the API.
The process of calling the API used to obtain the user token is described in Request. After a token is obtained, the X-Auth-Token header field must be added to requests to specify the token when calling other APIs. For example, if the token is ABCDEFJ...., X-Auth-Token: ABCDEFJ.... can be added to a request as follows:
GET https://iam.cn-north-1.myhuaweicloud.com/v3/auth/projects Content-Type: application/json X-Auth-Token: ABCDEFJ....
AK/SK Authentication
Authentication using the AK/SK supports API requests with a body not larger than 12 MB. For API requests with a larger body, authentication using tokens is recommended.
In authentication using the AK/SK, a pair of AK and SK is used to sign a request and add the signature to a request as its header for authentication.
- AK indicates the ID of the access key. It is the unique identifier associated with the SK. The AK and SK are used together to sign requests cryptographically.
- SK indicates the ID of the secret access key that is used together with AK to sign requests. AK and SK can be used together to identify a request sender and prevent the request from being modified.
In authentication using the AK/SK, you can use the AK/SK to sign requests based on the signature algorithm or use a dedicated signature SDK to sign the requests. For details on how to sign requests and use the signing SDKs, see API Request Signing Guide.
The signing SDK is only used for signing requests and is different from the SDKs provided by services.
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.