tencent cloud

Configuring Environment Variables
Last updated: 2025-11-07 17:40:37
Configuring Environment Variables
Last updated: 2025-11-07 17:40:37
Environment variables are variables used by the operating system to store system information, usually used for storage configuration information. When using the Tencent Cloud CLS SDK, it is recommended to specify TencentCloud API key information through environment variables. For key information acquisition, please visit API Key Management.
Note:
Do not store key information in project code files via plaintext, otherwise it may cause key information leakage and threaten your account security.
After configuring environment variables, you can transmit dynamic authentication parameters to corresponding functions without code modification, enabling convenient and secure identity verification.

Setting Environment Variables for Linux and macOS System

After configuring environment variables, the backend service will dynamically read the parameter values specified in the environment variables during the current session and apply them to the appropriate function. Replace YOUR_SECRET_ID and YOUR_SECRET_KEY with your actual cloud API key.
export TENCENTCLOUD_SECRET_ID="YOUR_SECRET_ID"
export TENCENTCLOUD_SECRET_KEY="YOUR_SECRET_KEY"

Setting Environment Variables for Windows Systems

After configuring environment variables, the backend service will dynamically read the parameter values specified in the environmental variables during the current session and apply them to the appropriate function. Replace YOUR_SECRET_ID and YOUR_SECRET_KEY with your actual cloud API key.

Set Via Windows Command Prompt

Run the following command to set environment variables:
set TENCENTCLOUD_SECRET_ID="YOUR_SECRET_ID"
set TENCENTCLOUD_SECRET_KEY="YOUR_SECRET_KEY"

Setting Via Windows PowerShell

Run the following command to set environment variables:
$Env:TENCENTCLOUD_SECRET_ID="YOUR_SECRET_ID"
$Env:TENCENTCLOUD_SECRET_KEY="YOUR_SECRET_KEY"

Setting Via Windows Graphical Interface

1. On the desktop, click PC, select Properties > Advanced System Setting > Environment Variables > System Variables/User Variables > Create.
2. Add the cloud API key to the associated environment variables and click Confirm.
Note:
Note: If needed, modify the corresponding parameters of environment variables to change the key value directly.

Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback