Skip to content

Commit fc6f3b9

Browse files
authored
feat(auth0): handle errors passed from Auth0 in query string (#456) (#457)
1 parent 988dfc6 commit fc6f3b9

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/runtime/server/lib/oauth/auth0.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,21 @@ export function defineOAuthAuth0EventHandler({ config, onSuccess, onError }: OAu
7777
const authorizationURL = `https://${config.domain}/authorize`
7878
const tokenURL = `https://${config.domain}/oauth/token`
7979

80-
const query = getQuery<{ code?: string }>(event)
80+
const query = getQuery<{ code?: string, error?: string, error_description?: string }>(event)
8181
const redirectURL = config.redirectURL || getOAuthRedirectURL(event)
8282

83+
if (query.error) {
84+
return handleAccessTokenErrorResponse(
85+
event,
86+
'auth0',
87+
{
88+
error: query.error,
89+
error_description: query.error_description,
90+
},
91+
onError,
92+
)
93+
}
94+
8395
if (!query.code) {
8496
config.scope = config.scope || ['openid', 'offline_access']
8597
if (config.emailRequired && !config.scope.includes('email')) {

0 commit comments

Comments
 (0)