Skip to content

Commit 657b3ed

Browse files
committed
fix: better error handling for github oauth
1 parent 05a4e08 commit 657b3ed

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/pages/api/auth/oauth/github.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,15 @@ async function handler({ code, state }: OAuthQuery, logger: Logger): Promise<OAu
6161

6262
const json = await res.json();
6363

64+
if (json.error) {
65+
logger.error('failed to fetch access token', {
66+
error: json.error_description ?? json.error_uri ?? json.error ?? 'unknown gh error',
67+
});
68+
logger.debug('failed to fetch access token', { json, status: res.status });
69+
70+
return { error: 'there was an error while processing github request' };
71+
}
72+
6473
if (!json.access_token) return { error: 'No access token in response' };
6574

6675
const userJson = await githubAuth.user(json.access_token);

0 commit comments

Comments
 (0)