Help Center > > API Reference> Calling APIs> Authentication

Authentication

Updated at: Jul 01, 2019 16:39

Calling an API can be authenticated using either of the following methods:

  • Authentication using tokens: General requests are authenticated using tokens.
  • Authentication using AK/SK: Requests are encrypted using access key ID (AK)/secret access key (SK). Authentication using AK/SK is recommended because it provides higher security than authentication using tokens.

Authentication Using Tokens

NOTE:

The validity period of a token is 24 hours. When using a token for authentication, cache it to prevent frequently calling the API.

A token specifies certain permissions in a computer system. Authentication using a token adds the token in a request as its header during API calling to obtain permissions to operate APIs.

In Making an API Request, the process of calling the API for obtaining a user token is described as an example. After obtaining the token, add the X-Auth-Token header in a request to specify the token when calling other APIs. For example, if the token is ABCDEFJ...., add X-Auth-Token: ABCDEFJ.... in a request as follows:

POST https://iam.cn-north-1.myhuaweicloud.com/v3/auth/projects

Content-Type: application/json
X-Auth-Token: ABCDEFJ....

Authentication Using AK/SK

NOTE:

Authentication using 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 AK/SK, AK/SK is used to sign a request and add the signature in a request as its header for authentication.

  • AK: access key ID, which is a unique identifier associated with a secret access key and is used in conjunction with a secret access key to sign requests cryptographically.
  • SK: secret access key used in conjunction with an AK to sign requests cryptographically. It identifies a request sender and prevents the request from being modified.
In authentication using AK/SK, you can use AK/SK to sign requests based on the signature algorithm or use a dedicated signature SDK to sign the requests. For details about how to sign requests and use the signature SDK, see API Signature Guide.

The signature SDK only supports signature, which is different from the SDKs provided by services.

Did you find this page helpful?

Submit successfully!

Thank you for your feedback. Your feedback helps make our documentation better.

Failed to submit the feedback. Please try again later.

Which of the following issues have you encountered?







Please complete at least one feedback item.

Content most length 200 character

Content is empty.

OK Cancel