mirror of
https://github.com/tickstep/aliyunpan.git
synced 2025-01-23 14:32:14 +08:00
add openapi token refresh hook
This commit is contained in:
parent
e8b87a02dc
commit
9dd2482b58
@ -133,10 +133,8 @@ doOpenLoginAct:
|
||||
}, openapi.ApiToken{
|
||||
AccessToken: openapiToken.AccessToken,
|
||||
ExpiredAt: openapiToken.Expired,
|
||||
}, func(newToken openapi.ApiToken) error {
|
||||
// TODO: save & refresh new token
|
||||
return nil
|
||||
})
|
||||
}, nil)
|
||||
|
||||
// open api token maybe expired
|
||||
// check & refresh new one
|
||||
openUserInfo, err := openPanClient.GetUserInfo()
|
||||
@ -229,6 +227,14 @@ doWebLoginAct:
|
||||
Workdir: "/",
|
||||
WorkdirFileEntity: *aliyunpan.NewFileEntityForRootDir(),
|
||||
}
|
||||
u.PanClient().OpenapiPanClient().SetAccessTokenRefreshCallback(func(userId string, newToken openapi.ApiToken) error {
|
||||
logger.Verboseln("openapi token refresh, update for user")
|
||||
u.OpenapiToken = &PanClientToken{
|
||||
AccessToken: newToken.AccessToken,
|
||||
Expired: newToken.ExpiredAt,
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
// setup user info
|
||||
name := "Unknown"
|
||||
|
@ -4,7 +4,7 @@
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@ -109,7 +109,7 @@ func DecryptString(text string) string {
|
||||
return string(r)
|
||||
}
|
||||
|
||||
// isFolderExist 判断文件夹是否存在
|
||||
// IsFolderExist 判断文件夹是否存在
|
||||
func IsFolderExist(pathStr string) bool {
|
||||
fi, err := os.Stat(pathStr)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user