Help Center/
KooGallery/
Access Guide/
SaaS Access Guide V2.0 (New Products)/
KooGallery Open APIs/
Using APIs/
AK/SK Authentication
Updated on 2024-05-09 GMT+08:00
AK/SK Authentication
Generating an AK and SK
- Register with Huawei Cloud and log in to the management console.
- Click the username and choose My Credentials from the drop-down list.
- In the navigation pane, choose Access Keys.
- Click Create Access Key.
- Enter the SMS or email verification code and click OK to download the access key. Keep the access key secure.
API requests sent by third-party applications to Huawei Cloud must be authenticated using signatures.
Preparation
- Download the APIG signing tool and decompress it.
- Create a Java project and reference the decompressed JAR file to the dependency path.
Procedure
- Create a com.cloud.sdk.DefaultRequest (JAVA) request used for signing.
- Set the destination API URL, HTTPS method, and content of DefaultRequest.
- Sign DefaultRequest.
- Call SignerFactory.getSigner(String serviceName, String regionName) to obtain a signature tool instance.
- Call Signer.sign(Request<?> request, Credentials credentials) to sign the request created in step 1.
The following code shows the details.
// Select the signing algorithm for signing the request. Signer signer = SignerFactory.getSigner(serviceName, region); // Sign the request. The request will change after being signed. signer.sign(request, new BasicCredentials(this.ak, this.sk));
- Convert the request signed in the previous step to one that can be used to make an API call and copy the header of the signed request to the new request.
- For example, for Apache HttpClient, convert DefaultRequest into HttpRequestBase and copy the header of the signed DefaultRequest to HttpRequestBase.
Parent topic: Using APIs
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
The system is busy. Please try again later.
For any further questions, feel free to contact us through the chatbot.
Chatbot