NextAuth: Custom AuthProvider
Unanswered
American Wirehair posted this in #help-forum
American WirehairOP
Hi, i have implemented a Custom OAuthProvider.
{
id: 'ouath',
name: 'ouath',
type: 'oauth',
clientId: CLIENT_ID,
clientSecret: CLIENT_SECRET,
issuer: 'some-issuer',
idToken: true,
wellKnown: '',
checks: ['state'],
authorization: {
params: {
scope: 'profile openid',
},
},
profile: async (profile: Profile, claims: Token): Promise<User> => {
logger.debug({ msg: 'Received response', profile, claims });
return await dependencies.authService.handleProfileCallback(profile, claims);
},
}
Could someone explain to me what happesn when an Error('UserCouldNotBeAuthenticated') is thrown by handleProfileCallback().
The only thing I see in my server logs is:
{
"level": 50,
"time": 1695901819140,
"name": "nextjs-backend",
"levelLabel": "error",
"source": "AuthConfig",
"code": "OAUTH_PARSE_PROFILE_ERROR",
"metadata": {
"error": {},
"OAuthProfile": {
...
}
}
}
Is it possbile to redirect the user to an /auth-error route from the backend?
Thank you very much!
{
id: 'ouath',
name: 'ouath',
type: 'oauth',
clientId: CLIENT_ID,
clientSecret: CLIENT_SECRET,
issuer: 'some-issuer',
idToken: true,
wellKnown: '',
checks: ['state'],
authorization: {
params: {
scope: 'profile openid',
},
},
profile: async (profile: Profile, claims: Token): Promise<User> => {
logger.debug({ msg: 'Received response', profile, claims });
return await dependencies.authService.handleProfileCallback(profile, claims);
},
}
Could someone explain to me what happesn when an Error('UserCouldNotBeAuthenticated') is thrown by handleProfileCallback().
The only thing I see in my server logs is:
{
"level": 50,
"time": 1695901819140,
"name": "nextjs-backend",
"levelLabel": "error",
"source": "AuthConfig",
"code": "OAUTH_PARSE_PROFILE_ERROR",
"metadata": {
"error": {},
"OAuthProfile": {
...
}
}
}
Is it possbile to redirect the user to an /auth-error route from the backend?
Thank you very much!