Hi,
After adding a generic passport-oauth2 provider in next-auth.providers.js, I'm running into this error on /auth/oauth/mycoolprovider:
TypeError: strategy.authenticate is not a function
at attempt (/Users/joshkadis/Repos/themostlaps_v2/node_modules/passport/lib/middleware/authenticate.js:361:16)
at authenticate (/Users/joshkadis/Repos/themostlaps_v2/node_modules/passport/lib/middleware/authenticate.js:362:7)
at Layer.handle [as handle_request] (/Users/joshkadis/Repos/themostlaps_v2/node_modules/express/lib/router/layer.js:95:5)
at next (/Users/joshkadis/Repos/themostlaps_v2/node_modules/express/lib/router/route.js:137:13)
# etc., etc...
It seems like Passport can't find the function registered for the named authentication strategy. Can you provide some documentation for this step from AUTHENTICATE.md?
Add a field to your User model (in 'index.js') with the name of the provider
Thanks for the rad library!
Thanks, sorry I haven't been able to answer this before now, I'll try and respond tomorrow!
Turns out that the above error was happening because Passport was registering the strategy as oauth2 rather than as the providerName from my next-auth.providers.js. I.e. Passport couldn't find a strategy called strava when I did it this way:
{
providerName: 'Strava',
Strategy: OAuth2Strategy.Strategy,
}
Changing the providerName to OAuth2 would have worked although I ended up using an open source Passport strategy for Strava.
Could still use a tip on the adding a field to the User model thing though. Thanks!
Thank you for the feeedback and follow up. Version 2.0 works much better with generic oAuth services, and is much easier to configure.
The documentation is a work in progress however, this is a good reminder to do that, moving this issue into milestone for 2.0.
This is now provided in the documentation of 2.0.
Most helpful comment
Turns out that the above error was happening because Passport was registering the strategy as
oauth2rather than as theproviderNamefrom mynext-auth.providers.js. I.e. Passport couldn't find a strategy calledstravawhen I did it this way:Changing the
providerNametoOAuth2would have worked although I ended up using an open source Passport strategy for Strava.Could still use a tip on the adding a field to the User model thing though. Thanks!