Skip to content

Commit a2f001e

Browse files
author
Peter Steinberger
committed
fix(auth): persist rotated refresh tokens (openclaw#373) (thanks @joshp123)
1 parent 59ab294 commit a2f001e

3 files changed

Lines changed: 4 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
- Contacts: send the required `copyMask` when deleting "other contacts", avoiding People API 400 errors. (#384) — thanks @rbansal42.
2121
- Calendar: hide cancelled/deleted events from `calendar events` list output by explicitly setting `showDeleted=false`. (#362) — thanks @sharukh010.
2222
- Calendar: use `Calendars.Get` for timezone lookups so service-account flows don’t 404 on `calendarList/primary`. (#325) — thanks @markwatson.
23+
- Auth: persist rotated OAuth refresh tokens returned during API calls so later commands keep working without re-auth. (#373) — thanks @joshp123.
2324
- Gmail: fall back to `MimeType` charset hints when `Content-Type` headers are missing so GBK/GB2312 message bodies decode correctly. (#428) — thanks @WinnCook.
2425
- Gmail: add a fetch delay in `watch serve` so History API reads don't race message indexing. (#397) — thanks @salmonumbrella.
2526
- Gmail: allow Workspace-managed send-as aliases with empty verification status in `send` and `drafts create`. (#407) — thanks @salmonumbrella.

internal/googleapi/client.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func newPersistingTokenSource(base oauth2.TokenSource, store secrets.Store, clie
6464
func (p *persistingTokenSource) Token() (*oauth2.Token, error) {
6565
t, err := p.base.Token()
6666
if err != nil {
67-
return nil, err
67+
return nil, fmt.Errorf("base token source: %w", err)
6868
}
6969

7070
refreshToken := strings.TrimSpace(t.RefreshToken)
@@ -147,6 +147,7 @@ func tokenSourceForAccountScopes(ctx context.Context, serviceLabel string, email
147147
ctx = context.WithValue(ctx, oauth2.HTTPClient, &http.Client{Timeout: tokenExchangeTimeout})
148148

149149
baseSource := cfg.TokenSource(ctx, &oauth2.Token{RefreshToken: tok.RefreshToken})
150+
150151
return newPersistingTokenSource(baseSource, store, client, email, tok), nil
151152
}
152153

internal/googleapi/client_more_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ func (s *stubStore) SetToken(client string, email string, tok secrets.Token) err
5151
}
5252

5353
s.tok = tok
54+
5455
return nil
5556
}
5657
func (s *stubStore) DeleteToken(string, string) error { return nil }

0 commit comments

Comments
 (0)