Use the default credential provider chain
masterIf you do not explicitly provide credentials, the SDK uses a default provider chain to look for credentials in the following order:
- System Properties: Checks for
alibabacloud.accessKeyIdandalibabacloud.accessKeyIdSecret. - Environment Credentials: Checks for
ALIBABA_CLOUD_ACCESS_KEY_IDandALIBABA_CLOUD_ACCESS_KEY_SECRETenvironment variables. - Credentials File: Looks for a configuration file at
~/.alibabacloud/credentials(orC:\Users\USER_NAME\.alibabacloud\credentialson Windows).- You can change the file path using the
ALIBABA_CLOUD_CREDENTIALS_FILEenvironment variable. - You can select a specific profile using the
ALIBABA_CLOUD_PROFILEenvironment variable.
- You can change the file path using the
- Instance RAM Role: If
ALIBABA_CLOUD_ECS_METADATAis defined, the SDK fetches temporary security credentials from the ECS metadata service.
To use the default chain, simply initialize the client with a region ID:
IAcsClient client = new DefaultAcsClient("your-region-id");