Skip to content

Commit 38556ca

Browse files
authored
Merge pull request #49 from LyricTian/develop
update refreshing token config
2 parents 4c69c58 + d85b5f3 commit 38556ca

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

manage/config.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ type Config struct {
1414

1515
// RefreshingConfig refreshing token config
1616
type RefreshingConfig struct {
17+
// access token expiration time
18+
AccessTokenExp time.Duration
19+
// refresh token expiration time
20+
RefreshTokenExp time.Duration
1721
// whether to generate the refreshing token
1822
IsGenerateRefresh bool
1923
// whether to reset the refreshing create time

manage/manager.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,14 @@ func (m *Manager) RefreshAccessToken(tgr *oauth2.TokenGenerateRequest) (accessTo
373373
ti.SetAccess(tv)
374374
ti.SetAccessCreateAt(td.CreateAt)
375375

376+
if v := rcfg.AccessTokenExp; v > 0 {
377+
ti.SetAccessExpiresIn(v)
378+
}
379+
380+
if v := rcfg.RefreshTokenExp; v > 0 {
381+
ti.SetRefreshExpiresIn(v)
382+
}
383+
376384
if rcfg.IsResetRefreshTime {
377385
ti.SetRefreshCreateAt(td.CreateAt)
378386
}

0 commit comments

Comments
 (0)