fix(auth): preserve extra scopes replay and satisfy lint on current main (#421) (thanks @peteradams2026)
Some checks failed
ci / test (push) Has been cancelled
ci / worker (push) Has been cancelled
ci / windows (push) Has been cancelled
ci / darwin-cgo-build (push) Has been cancelled

This commit is contained in:
Peter Steinberger 2026-03-08 03:17:52 +00:00
parent b10c81a989
commit 2bd8c347d0
3 changed files with 6 additions and 3 deletions

View File

@ -427,11 +427,12 @@ func writeWatchState(ctx context.Context, state gmailWatchState, showSecrets boo
u.Out().Printf("hook_max_bytes\t%d", state.Hook.MaxBytes)
}
if state.Hook.Token != "" {
if showSecrets {
switch {
case showSecrets:
u.Out().Printf("hook_token\t%s", state.Hook.Token)
} else if len(state.Hook.Token) > 4 {
case len(state.Hook.Token) > 4:
u.Out().Printf("hook_token\t%s...(%d chars)", state.Hook.Token[:4], len(state.Hook.Token))
} else {
default:
u.Out().Printf("hook_token\t[REDACTED]")
}
}

View File

@ -391,6 +391,7 @@ func ScopesForManageWithOptions(services []Service, opts ScopeOptions) ([]string
if len(opts.ExtraScopes) > 0 {
merged = mergeScopes(merged, opts.ExtraScopes)
}
return merged, nil
}

View File

@ -519,6 +519,7 @@ func TestScopesForManageWithOptions_ExtraScopes(t *testing.T) {
// De-duplication: gmail.readonly should appear exactly once
count := 0
for _, s := range scopes {
if s == "https://www.googleapis.com/auth/gmail.readonly" {
count++