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{
|
}, openapi.ApiToken{
|
||||||
AccessToken: openapiToken.AccessToken,
|
AccessToken: openapiToken.AccessToken,
|
||||||
ExpiredAt: openapiToken.Expired,
|
ExpiredAt: openapiToken.Expired,
|
||||||
}, func(newToken openapi.ApiToken) error {
|
}, nil)
|
||||||
// TODO: save & refresh new token
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
// open api token maybe expired
|
// open api token maybe expired
|
||||||
// check & refresh new one
|
// check & refresh new one
|
||||||
openUserInfo, err := openPanClient.GetUserInfo()
|
openUserInfo, err := openPanClient.GetUserInfo()
|
||||||
@ -229,6 +227,14 @@ doWebLoginAct:
|
|||||||
Workdir: "/",
|
Workdir: "/",
|
||||||
WorkdirFileEntity: *aliyunpan.NewFileEntityForRootDir(),
|
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
|
// setup user info
|
||||||
name := "Unknown"
|
name := "Unknown"
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
// You may obtain a copy of the License at
|
// 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
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
@ -109,7 +109,7 @@ func DecryptString(text string) string {
|
|||||||
return string(r)
|
return string(r)
|
||||||
}
|
}
|
||||||
|
|
||||||
// isFolderExist 判断文件夹是否存在
|
// IsFolderExist 判断文件夹是否存在
|
||||||
func IsFolderExist(pathStr string) bool {
|
func IsFolderExist(pathStr string) bool {
|
||||||
fi, err := os.Stat(pathStr)
|
fi, err := os.Stat(pathStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user