Configure Authentication Credentials
masterHuawei Cloud services are categorized into Region-level and Global-level services. Choosing the correct credential class is critical:
- Region-level services: Use
BasicCredentialsand must provide aproject_id. - Global-level services (e.g., IAM, RMS, TMS): Use
GlobalCredentialsand must provide adomain_id.
Supported Authentication Methods
1. Temporary AK/SK & SecurityToken
Used when obtaining temporary credentials via IAM (e.g., CreateTemporaryAccessKeyByToken).
2. Permanent AK/SK
Standard Access Key and Secret Key. Security Note: It is recommended to use IAM users with minimal permissions rather than the master account.
3. IdpId & IdTokenFile
Used for Federated Authentication via OpenID Connect (OIDC). Requires an idp_id and a file path to the id_token.
from huaweicloudsdkcore.auth.credentials import BasicCredentials, GlobalCredentials
# Region-level with Temporary Credentials
basic_credentials = BasicCredentials(ak, sk, project_id).with_security_token(security_token)
# Global-level with Permanent Credentials
global_credentials = GlobalCredentials(ak, sk, domain_id)
# Federated Authentication (Region-level)
basic_cred = BasicCredentials() \
.with_idp_id(idp_id) \
.with_id_token_file(id_token_file) \
.with_project_id(project_id)