Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example for generic OAuth2? #32

Closed
joshkadis opened this issue Jun 8, 2018 · 4 comments
Closed

Example for generic OAuth2? #32

joshkadis opened this issue Jun 8, 2018 · 4 comments
Labels
documentation Relates to documentation question Ask how to do something or how something works
Milestone

Comments

@joshkadis
Copy link

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!

@iaincollins iaincollins added the question Ask how to do something or how something works label Jun 12, 2018
@iaincollins
Copy link
Member

Thanks, sorry I haven't been able to answer this before now, I'll try and respond tomorrow!

@joshkadis
Copy link
Author

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!

@iaincollins
Copy link
Member

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.

@iaincollins iaincollins added the documentation Relates to documentation label May 9, 2020
@iaincollins iaincollins added this to the 2.0 milestone May 9, 2020
@LoriKarikari
Copy link
Contributor

This is now provided in the documentation of 2.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Relates to documentation question Ask how to do something or how something works
Projects
None yet
Development

No branches or pull requests

3 participants