Skip to content

Commit

Permalink
Porsche: validate token every 5min
Browse files Browse the repository at this point in the history
  • Loading branch information
andig committed Jul 6, 2023
1 parent 95b3b00 commit 16d0b02
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions vehicle/porsche/identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,15 @@ func (v *Identity) Login(oc *oauth2.Config, user, password string) error {
}

ts := oc.TokenSource(cctx, token)
v.TokenSource = oauth2.ReuseTokenSourceWithExpiry(token, ts, 6*time.Hour)
v.TokenSource = oauth2.ReuseTokenSourceWithExpiry(token, ts, 15*time.Minute)

go v.refresh()

return nil
}

func (v *Identity) refresh() {
for range time.Tick(time.Hour) {
for range time.Tick(5 * time.Minute) {
if _, err := v.Token(); err != nil {
v.log.ERROR.Printf("token refresh: %v", err)
}
Expand Down

0 comments on commit 16d0b02

Please sign in to comment.