`getClientCredentialsToken()` sends `scopes` (comma-joined) instead of the OAuth `scope` parameter
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Accessibilité débutants
- 82/100
- Type d'issue
- Bug
- Clarté
- Clairement spécifiée
- Activité
- Active
- Stack technique
- node.js, typescript
- Domaine
- api, authentication
Piste de recherche
Commence par getClientCredentialsToken() dans src/XeroClient.ts et examine comment tokenRequest() encode le corps. Vérifie les exemples du README aux lignes 172 et 236 pour repérer les indications contradictoires. Le travail est terminé lorsque la requête de jeton envoie les scopes demandés sous la forme d’un paramètre scope séparé par des espaces et que le commentaire du README correspond au comportement.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Which version of the SDK are you using?
20.3.0 (master at 538aa65)
Summary
getClientCredentialsToken() passes the configured scopes to the token endpoint under the key scopes:
https://github.com/XeroAPI/xero-node/blob/538aa65/src/XeroClient.ts#L196-L198
const { clientId, clientSecret, grantType, scopes } = this.config;
const result = await this.tokenRequest(clientId, clientSecret, { grant_type: grantType, scopes });
encodeBody() then runs encodeURIComponent on the array, which joins it with commas. The request body is:
POST https://identity.xero.com/connect/token
grant_type=client_credentials&scopes=accounting.transactions%2Caccounting.contacts
(captured by stubbing axios and calling getClientCredentialsToken() with scopes: ['accounting.transactions', 'accounting.contacts'])
The token endpoint expects the standard scope parameter, space-delimited (RFC 6749 §4.4.2). scopes isn't a token request parameter, so the requested scopes are not actually requested and the token falls back to whatever the connection grants by default. That breaks the README example that relies on requesting marketplace.billing for App Store calls (README L172). It also means an app can't narrow a custom-connection token to fewer scopes.
xero-python already does this correctly (post_data["scope"] = "marketplace.billing").
Suggested fix
const body: Record<string, string> = { grant_type: grantType };
if (scopes?.length) body.scope = scopes.join(' ');
const result = await this.tokenRequest(clientId, clientSecret, body);
The README comment at L236 (scopes ... // not used for client_credentials auth flow) contradicts L172 and could be updated at the same time.
- Langage dominant
- TypeScript
- Étoiles
- 264
- Forks
- 177
- Merge moyen
- 10 h 5 min
- PR mergées (30 j)
- 5
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de XeroAPI/xero-node
-
Difficulté 3/5 Une demi-journée Accessibilité débutants 55/100
-
TrackingOptionId value missing from accountingApi.getInvoices()Peut-être pris @miachillgood l’a pris il y a 152 jours. Ouverte
Difficulté 3/5 1-2 jours Accessibilité débutants 18/100
-
BankTransaction type is missing the batchPayment object.Peut-être pris @miachillgood l’a pris il y a 171 jours. Ouverte
Difficulté 3/5 1-2 jours Accessibilité débutants 22/100
-
Difficulté 3/5 1-2 jours Accessibilité débutants 25/100
-
Difficulté 3/5 1-2 jours Accessibilité débutants 35/100
Toutes les issues de XeroAPI/xero-node
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
super-productivity/super-productivity#12128 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
A docs change can fail pnpm check, because outreach lint and gen:types both write .astro/ at oncePeut-être pris @2389400626lh-ops l’a pris aujourd’hui. OuverteArea: Infrastructure Area: Outreach Bug Difficulty: Low Good First Issue Priority: Low
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
DouglasNeuroInformatics/OpenDataCapture#1956 ·
Les mainteneurs répondent en général sous 1 jour
-
enhancement
Difficulté 2/5 1-3 heures Accessibilité débutants 77/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 1/5 1-3 heures Accessibilité débutants 72/100
justyns/silverbullet-ai#199 ·
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 83/100
spartan-ng/spartan#1931 ·
Les mainteneurs répondent en général sous 2 jours