gmail +read returns 403 quota-project error when authenticated with default scopes

Ouverte
#843 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

  • #939 par @mittalpk — fermée sans fusion

Évaluation

Difficulté
3/5
Temps estimé
1-2 jours
Accessibilité débutants
75/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Calme
Stack technique
rust
Domaine
authentication, cli

Piste de recherche

Start in the +read helper at fetch_message_metadata and trace its use of crate::client::build_client() and send_with_retry, comparing it with executor.rs and auth::get_quota_project(). Verify the reproduction commands, then confirm that +read supplies the quota project header and succeeds with default scopes without breaking the documented non-project-member case.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

gws gmail +read fails with:

Your application is authenticating by using local Application Default Credentials.
The gmail.googleapis.com API requires a quota project, which is not set by default.

The equivalent raw command succeeds:

gws gmail users messages get --params '{"userId":"me","id":"<id>","format":"full"}'

Cause

Google identifies tokens from the Cloud SDK client (764086051850-...) as ADC and requires the x-goog-user-project header. Standard resource commands go through executor.rs, which calls auth::get_quota_project() and adds the header. The +read helper bypasses executor.rs and calls fetch_message_metadata directly via crate::client::build_client() and send_with_retry. The request goes out with .bearer_auth(token) only, no quota project header.

This gap exists because #242 moved the x-goog-user-project injection from build_client() into executor.rs. When +read was added in #526, it called build_client() directly and missed the header.

Reproduction

gws auth login   # default scopes (gmail.modify)
gws gmail +read --id <any-message-id>
# -> 403 accessNotConfigured
gws gmail users messages get --params '{"userId":"me","id":"<id>","format":"full"}'
# -> succeeds

Adding gmail.readonly to the token does not help — the scope is irrelevant. The missing header is the sole cause.

Related

  • #242 — moved x-goog-user-project from build_client() to executor.rs
  • #526 — introduced +read bypassing executor.rs
  • #729 / #827 — inverse problem where the header causes 403 for non-project-member OAuth users

Suggested fix

Add x-goog-user-project via auth::get_quota_project() in fetch_message_metadata (and other helper functions that bypass executor.rs). Same trade-off as #729 applies.

Alternatively, refactor helpers to route through executor.rs or a shared request-building function that handles auth headers consistently.

Workaround

gws gmail users messages get --params '{"userId":"me","id":"<message-id>","format":"full"}'

Environment

  • gws 0.22.5, macOS (Apple Silicon)
  • Auth: OAuth desktop, keyring backend
  • Confirmed with both gmail.modify only and gmail.modify + gmail.readonly
  • ADC quota_project_id set to a project with Gmail API enabled (irrelevant — build_client() does not propagate it)
Langage dominant
Rust
Étoiles
32.3k
Forks
2k
Merge moyen
16 h 3 min
PR mergées (30 j)
1

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de googleworkspace/cli

Toutes les issues de googleworkspace/cli

Issues similaires

Plus d'issues Rust

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.