`getClientCredentialsToken()` sends `scopes` (comma-joined) instead of the OAuth `scope` parameter
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 82/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- node.js, typescript
- Área
- api, authentication
Línea de trabajo
Empieza con getClientCredentialsToken() en src/XeroClient.ts e inspecciona cómo tokenRequest() codifica el cuerpo. Comprueba los ejemplos del README en las líneas 172 y 236 para localizar las indicaciones contradictorias. El trabajo estará terminado cuando la solicitud del token envíe los scopes solicitados como un parámetro scope separado por espacios y el comentario del README coincida con el comportamiento.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- TypeScript
- Estrellas
- 264
- Forks
- 177
- Merge medio
- 10 h 5 min
- PR fusionados (30 d)
- 5
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de XeroAPI/xero-node
-
Dificultad 3/5 Medio día Aptitud para principiantes 55/100
-
TrackingOptionId value missing from accountingApi.getInvoices()Posiblemente ocupada @miachillgood la tomó hace 152 días. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 18/100
-
BankTransaction type is missing the batchPayment object.Posiblemente ocupada @miachillgood la tomó hace 171 días. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 22/100
-
Dificultad 3/5 1-2 días Aptitud para principiantes 25/100
-
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
Todos los issues de XeroAPI/xero-node
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
super-productivity/super-productivity#12128 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
A docs change can fail pnpm check, because outreach lint and gen:types both write .astro/ at oncePosiblemente ocupada @2389400626lh-ops la tomó hoy. AbiertoArea: Infrastructure Area: Outreach Bug Difficulty: Low Good First Issue Priority: Low
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
DouglasNeuroInformatics/OpenDataCapture#1956 ·
Los mantenedores suelen responder en 1 día
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 72/100
justyns/silverbullet-ai#199 ·
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
spartan-ng/spartan#1931 ·
Los mantenedores suelen responder en 2 días