All Products
Search
Document Center

Direct Mail:Configure the authentication AccessKey in the environment variable

Last Updated:Mar 06, 2024

Background information

Direct Mail products can use the SDK provided by the product to call API interfaces, and your identity needs to be verified when calling, and the method of configuring identity verification in environment variables does not need to be hard-coded with plaintext AK and other information in the code, which can effectively ensure the security of cloud resources under your account.

Prerequisites

We recommend that you create a RAM account to isolate your business from your Alibaba Cloud account. This way, you can use all Alibaba Cloud services without information leakage.

Obtain the AccessKey ID and AccessKey secret of the RAM user account.

Procedure

1.Create a RAM user

image

2.Create an AccessKey

Copy the AccessKey ID and AccessKey Secret for backup.

image

3. Configure environment variables

Windows operating system:

Press win+R open the run command window ,run 'sysdm.cpl' command.

Go to Advanced Tab,click on 'Environment Variables'

image..png

Create ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET. The values are the AccessKey ID and AccessKey secret created in the preceding step.

image

Restart the Windows operating system.

Linux operating system:

1. Open the terminal (command-line interface)

2. Use the following command to open the environment variable file, such as ~/.bashrc:

vi ~/.bashrc

3. Add the environment variables to be set at the end of the file, for example:

export ALIBABA_CLOUD_ACCESS_KEY_ID=<access_key_id>
export ALIBABA_CLOUD_ACCESS_KEY_SECRET=<access_key_secret>

4. Press the Esc key and enter: wq to save and exit.

5. Run the following command to make the modified environment variables take effect:

source ~/.bashrc

6. If the corresponding path can be correctly output, the environment variable has been set successfully.

echo $ALIBABA_CLOUD_ACCESS_KEY_ID
echo $ALIBABA_CLOUD_ACCESS_KEY_SECRET