MCPcopy Create free account
hub / github.com/ClydeTime/Surge / GetAuthorizationKey

Function GetAuthorizationKey

Script/Task/ADrive.js:55–94  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

53}
54
55function GetAuthorizationKey() {
56 let option = {
57 url: 'https://auth.aliyundrive.com/v2/account/token',
58 headers: {
59 'Content-Type': 'application/json',
60 'accept': '*/*',
61 'accept-language': 'zh-CN,zh-Hansq=0.9',
62 'x-canary': ADriveInfo.headers['x-canary'],
63 'x-device-id': ADriveInfo.headers['x-device-id'],
64 'cookie': ADriveInfo.headers['cookie'],
65 'user-agent': ADriveInfo.headers['user-agent']
66 },
67 body: $.toStr(ADriveInfo.refresh_token_body)
68 }
69 $.log('获取authorization')
70 $.post(option, function (error, response, data) {
71 if (error) {
72 $.log('错误原因:' + error)
73 $.msg($.name, '❌签到失败', '刷新authorization失败')
74 $.done()
75 } else if (!data) {
76 $.log('没有获取到数据')
77 } else {
78 let body = $.toObj(data)
79 let refresh_token = body.refresh_token
80 let accessKey = 'Bearer ' + body.access_token
81 if (refresh_token) {
82 ADriveInfo.refresh_token_body.refresh_token = refresh_token
83 ADriveInfo.refresh_token = refresh_token
84 let t = $.setjson(ADriveInfo, keyName)
85 if (t) {
86 $.log('刷新阿里网盘refresh_token成功 🎉')
87 } else {
88 $.msg('刷新阿里网盘refresh_token失败‼️', '', '')
89 }
90 }
91 signCheckin(accessKey)
92 }
93 })
94}
95
96function signCheckin(authorization) {
97 let date = new Date()

Callers 1

ADrive.jsFile · 0.85

Calls 8

signCheckinFunction · 0.85
toStrMethod · 0.45
logMethod · 0.45
postMethod · 0.45
msgMethod · 0.45
doneMethod · 0.45
toObjMethod · 0.45
setjsonMethod · 0.45

Tested by

no test coverage detected