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:
It is not recommended to store secret key information in plain text within the executed project code files, as this may lead to key information leakage and compromise your account security.
After configuring environment variables, you can pass dynamic authentication parameters to corresponding functions without modifying the code, achieving secure and convenient identity authentication.
Setting Environment Variables for Linux and macOS System
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.
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. Right-click This PC on the desktop, choose Properties > Advanced system settings > Environment Variables > System Variables/User Variables > New.
2. Add the cloud API key to the associated environment variables and click Confirm.
Note:
If needed later, simply modify the corresponding parameter values in the environment variables to update the secret key values.