|
123456789101112131415161718192021222324252627 |
- package aliyun
-
- import (
- openapi "github.com/alibabacloud-go/darabonba-openapi/v2/client"
- dypnsapi20170525 "github.com/alibabacloud-go/dypnsapi-20170525/v2/client"
- "github.com/alibabacloud-go/tea/tea"
- )
-
- // Description:
- // 使用AK&SK初始化账号Client
- // @return Client
- // @throws Exception
- func CreateClient(accessKeyId, accessKeySecret string) (_result *dypnsapi20170525.Client, _err error) {
- // 工程代码泄露可能会导致 AccessKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考。
- // 建议使用更安全的 STS 方式,更多鉴权访问方式请参见:https://help.aliyun.com/document_detail/378661.html。
- config := &openapi.Config{
- // 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID。
- AccessKeyId: tea.String(accessKeyId),
- // 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_SECRET。
- AccessKeySecret: tea.String(accessKeySecret),
- }
- // Endpoint 请参考 https://api.aliyun.com/product/Dypnsapi
- config.Endpoint = tea.String("dypnsapi.aliyuncs.com")
- _result = &dypnsapi20170525.Client{}
- _result, _err = dypnsapi20170525.NewClient(config)
- return _result, _err
- }
|