Describe the bug
In the documentation, profileUrl and profile for custom providers are said to be not required in documentation but the application will crash if they are not given. This error is also the root of issue #209 as discovered by @ospira.
Steps to reproduce
Steps to reproduce the behavior.
- Create custom provider
- Omit
profileUrl and/or profile
Expected behavior
Authentication to succeed and profile to be set to undefined.
Screenshots or error logs
[next-auth][error][oauth_get_access_token_error] [
TypeError [ERR_INVALID_ARG_TYPE]: The "url" argument must be of type string. Received undefined
at new NodeError (node:internal/errors:278:15)
at validateString (node:internal/validators:123:11)
at Url.parse (node:url:160:3)
at Object.urlParse [as parse] (node:url:155:13)
at exports.OAuth2._request (/Users/jackhedaya/Desktop/thoughtful-fish/node_modules/oauth/lib/oauth2.js:72:22)
at /Users/jackhedaya/Desktop/thoughtful-fish/node_modules/next-auth/dist/server/lib/oauth/client.js:240:12
at new Promise (<anonymous>)
at exports.OAuth2.<anonymous> (/Users/jackhedaya/Desktop/thoughtful-fish/node_modules/next-auth/dist/server/lib/oauth/client.js:239:12)
...
Additional context
Original custom Provider:
NextAuth(req, res, {
providers: [
{
id: '[redacted]',
name: '[redacted]',
type: 'oauth',
version: '2.0',
accessTokenUrl: '[redacted]',
requestTokenUrl: '[redacted]',
authorizationUrl: `[redacted]`,
clientId: process.env.CONSUMER_KEY,
params: {
grant_type: 'authorization_code',
},
},
],
debug: true,
})
Working custom provider:
NextAuth(req, res, {
providers: [
{
id: '[redacted]',
name: '[redacted]',
type: 'oauth',
version: '2.0',
accessTokenUrl: '[redacted]',
requestTokenUrl: '[redacted]',
authorizationUrl: `[redacted]`,
clientId: process.env.CONSUMER_KEY,
params: {
grant_type: 'authorization_code',
},
profileUrl: '[redacted]',
profile: (p) => {
return {
id: p.userId
}
},
},
],
debug: true,
})
Describe the bug
In the documentation,
profileUrlandprofilefor custom providers are said to be not required in documentation but the application will crash if they are not given. This error is also the root of issue #209 as discovered by @ospira.Steps to reproduce
Steps to reproduce the behavior.
profileUrland/orprofileExpected behavior
Authentication to succeed and
profileto be set to undefined.Screenshots or error logs
Additional context
Original custom Provider:
Working custom provider: