Initializing the API Client
Sample Code
1 2 3 4 5 6 7 8 | //Create an API client in a specified region.
ApiClient apiClient = new ApiClient("regionName");
//Use token authentication.
apiClient.useToken("accountName", "userName", "password", "projectId");
//Use AK/SK authentication.
apiClient.useAksk("ak", "sk");
//Use AK/SK authentication. You must specify projectId if you use AK/SK authentication for a customized project.
apiClient.useAksk("ak", "sk", "projectId");
|
- AK/SK authentication is supported in 1.1.1 and later versions.
- In the example, regionName is the name of the region to which the service belongs. For example, regionName for the CN North-Beijing1 region is cn-north-1. For details about other region names, see Regions and Endpoints.
- accountName, userName, and password indicate the account name, username, and password of a HUAWEI CLOUD user, respectively. You can log in to the management console and obtain the information from the My Credentials page.
- projectId indicates the project ID. For details about how to obtain the project ID, see How Do I Obtain the Project ID?.
- For details about how to obtain the AK/SK, see How Do I Obtain the AK/SK?.
- If you use AK/SK authentication for a customized project, you must specify projectId.
Last Article: Job Management
Next Article: Registering to Use CS
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.