print body in OAuth 2 http errors

This commit is contained in:
Gregory Schier
2025-05-16 08:16:18 -07:00
parent 9615d3e29b
commit c73f0b02bd
2 changed files with 8 additions and 8 deletions

View File

@@ -53,11 +53,11 @@ export async function getAccessToken(
const resp = await ctx.httpRequest.send({ httpRequest }); const resp = await ctx.httpRequest.send({ httpRequest });
if (resp.status < 200 || resp.status >= 300) { const body = resp.bodyPath ? readFileSync(resp.bodyPath, 'utf8') : '';
throw new Error('Failed to fetch access token with status=' + resp.status);
}
const body = readFileSync(resp.bodyPath ?? '', 'utf8'); if (resp.status < 200 || resp.status >= 300) {
throw new Error('Failed to fetch access token with status=' + resp.status + ' and body=' + body);
}
let response; let response;
try { try {

View File

@@ -73,11 +73,11 @@ export async function getOrRefreshAccessToken(ctx: Context, contextId: string, {
return null; return null;
} }
if (resp.status < 200 || resp.status >= 300) { const body = resp.bodyPath ? readFileSync(resp.bodyPath, 'utf8') : '';
throw new Error('Failed to fetch access token with status=' + resp.status);
}
const body = readFileSync(resp.bodyPath ?? '', 'utf8'); if (resp.status < 200 || resp.status >= 300) {
throw new Error('Failed to refresh access token with status=' + resp.status + ' and body=' + body);
}
let response; let response;
try { try {