76 lines
2.3 KiB
Go
76 lines
2.3 KiB
Go
// This file is auto-generated, don't edit it. Thanks.
|
|
package alibaba
|
|
|
|
import (
|
|
openapi "github.com/alibabacloud-go/darabonba-openapi/v2/client"
|
|
dingtalkdrive_1_0 "github.com/alibabacloud-go/dingtalk/drive_1_0"
|
|
dingtalkoauth2_1_0 "github.com/alibabacloud-go/dingtalk/oauth2_1_0"
|
|
dingtalkstorage_1_0 "github.com/alibabacloud-go/dingtalk/storage_1_0"
|
|
dingtalkstorage_2_0 "github.com/alibabacloud-go/dingtalk/storage_2_0"
|
|
|
|
"github.com/alibabacloud-go/tea/tea"
|
|
)
|
|
|
|
const (
|
|
UNIONID = "YWjeT8Ltk2mUOP82QyMe0AiEiE"
|
|
SPACEID = "28057154815"
|
|
DENTRYID = "QBnd5ExVEaO9372acAdE2RzmVyeZqMmz"
|
|
)
|
|
|
|
/**
|
|
* 使用 Token 初始化账号Client
|
|
* @return Client
|
|
* @throws Exception
|
|
*/
|
|
func CreateClient() (_result *dingtalkoauth2_1_0.Client, _err error) {
|
|
config := &openapi.Config{}
|
|
config.Protocol = tea.String("https")
|
|
config.RegionId = tea.String("central")
|
|
_result = &dingtalkoauth2_1_0.Client{}
|
|
_result, _err = dingtalkoauth2_1_0.NewClient(config)
|
|
return _result, _err
|
|
}
|
|
|
|
func CreateStorageClientV2() (_result *dingtalkstorage_2_0.Client, _err error) {
|
|
config := &openapi.Config{}
|
|
config.Protocol = tea.String("https")
|
|
config.RegionId = tea.String("central")
|
|
_result = &dingtalkstorage_2_0.Client{}
|
|
_result, _err = dingtalkstorage_2_0.NewClient(config)
|
|
return _result, _err
|
|
}
|
|
|
|
func CreateStorageClientV1() (_result *dingtalkstorage_1_0.Client, _err error) {
|
|
config := &openapi.Config{}
|
|
config.Protocol = tea.String("https")
|
|
config.RegionId = tea.String("central")
|
|
_result = &dingtalkstorage_1_0.Client{}
|
|
_result, _err = dingtalkstorage_1_0.NewClient(config)
|
|
return _result, _err
|
|
}
|
|
|
|
func GetToken() (string, error) {
|
|
client, err := CreateClient()
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
getAccessTokenRequest := &dingtalkoauth2_1_0.GetAccessTokenRequest{
|
|
AppKey: tea.String("dingrmgtodzxaik76jpc"),
|
|
AppSecret: tea.String("RDZLaE0sxzOM0oz41iK1pHshU1W1w_XSGfiDAogUEauLq5iuxulSdZD4LGJtHwW7"),
|
|
}
|
|
resp, err := client.GetAccessToken(getAccessTokenRequest)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
return *resp.Body.AccessToken, nil
|
|
}
|
|
|
|
func CreateDriveClient() (_result *dingtalkdrive_1_0.Client, _err error) {
|
|
config := &openapi.Config{}
|
|
config.Protocol = tea.String("https")
|
|
config.RegionId = tea.String("central")
|
|
_result = &dingtalkdrive_1_0.Client{}
|
|
_result, _err = dingtalkdrive_1_0.NewClient(config)
|
|
return _result, _err
|
|
}
|