Skip to content
This repository was archived by the owner on May 29, 2025. It is now read-only.

Commit c73f0b0

Browse files
committed
print body in OAuth 2 http errors
1 parent 9615d3e commit c73f0b0

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

plugins/auth-oauth2/src/getAccessToken.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ export async function getAccessToken(
5353

5454
const resp = await ctx.httpRequest.send({ httpRequest });
5555

56+
const body = resp.bodyPath ? readFileSync(resp.bodyPath, 'utf8') : '';
57+
5658
if (resp.status < 200 || resp.status >= 300) {
57-
throw new Error('Failed to fetch access token with status=' + resp.status);
59+
throw new Error('Failed to fetch access token with status=' + resp.status + ' and body=' + body);
5860
}
5961

60-
const body = readFileSync(resp.bodyPath ?? '', 'utf8');
61-
6262
let response;
6363
try {
6464
response = JSON.parse(body);

plugins/auth-oauth2/src/getOrRefreshAccessToken.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ export async function getOrRefreshAccessToken(ctx: Context, contextId: string, {
7373
return null;
7474
}
7575

76+
const body = resp.bodyPath ? readFileSync(resp.bodyPath, 'utf8') : '';
77+
7678
if (resp.status < 200 || resp.status >= 300) {
77-
throw new Error('Failed to fetch access token with status=' + resp.status);
79+
throw new Error('Failed to refresh access token with status=' + resp.status + ' and body=' + body);
7880
}
7981

80-
const body = readFileSync(resp.bodyPath ?? '', 'utf8');
81-
8282
let response;
8383
try {
8484
response = JSON.parse(body);

0 commit comments

Comments
 (0)