Bug
When running gmail watch serve --client personal --account user@gmail.com, the --client flag is correctly parsed and used to resolve the account in requireAccount(flags), but it is not propagated to the context used by the push handler. When a push notification arrives and the server calls newGmailService(ctx, account), the client override is missing from the context, causing authclient.ResolveClient() to fall back to "default".
This means multi-client setups (e.g., a company account on default and a personal account on personal) always fail for non-default clients:
watch: handle push failed: gmail options: token source: auth required for gmail user@gmail.com (client default)
Root cause
In root.go:150, the --client flag is injected into the context:
ctx = authclient.WithClient(ctx, cli.Client)
However, gmail_watch_server.go creates new contexts for incoming HTTP requests (via r.Context()), which don't inherit the root context's client override. The gmailWatchServer struct has no client field to carry this through.
Suggested fix
Store the client name in gmailWatchServerConfig and wrap each request context with authclient.WithClient() before calling newService:
// In gmail_watch_server.go, handlePush or wherever ctx is created from the request:
ctx = authclient.WithClient(r.Context(), s.cfg.Client)
Repro
# Register two accounts with different clients
gog auth add chrys@company.co --client default --services gmail
gog auth add user@gmail.com --client personal --services gmail
# Start watch serve for the personal account
gog gmail watch serve --client personal --account user@gmail.com --port 8802
# Send a push notification → fails with "auth required ... (client default)"
Version
gog v0.11.0 (91c4c15)
Bug
When running
gmail watch serve --client personal --account user@gmail.com, the--clientflag is correctly parsed and used to resolve the account inrequireAccount(flags), but it is not propagated to the context used by the push handler. When a push notification arrives and the server callsnewGmailService(ctx, account), the client override is missing from the context, causingauthclient.ResolveClient()to fall back to"default".This means multi-client setups (e.g., a company account on
defaultand a personal account onpersonal) always fail for non-default clients:Root cause
In
root.go:150, the--clientflag is injected into the context:However,
gmail_watch_server.gocreates new contexts for incoming HTTP requests (viar.Context()), which don't inherit the root context's client override. ThegmailWatchServerstruct has noclientfield to carry this through.Suggested fix
Store the client name in
gmailWatchServerConfigand wrap each request context withauthclient.WithClient()before callingnewService:Repro
Version
gog v0.11.0 (91c4c15)