jaredhanson / passport-oauth2

OAuth 2.0 authentication strategy for Passport and Node.js.
https://www.passportjs.org/packages/passport-oauth2/?utm_source=github&utm_medium=referral&utm_campaign=passport-oauth2&utm_content=about
MIT License
607 stars 343 forks source link

v1.5+ Breaks OAuth2Strategy callback #155

Open Number16BusShelter opened 2 years ago

Number16BusShelter commented 2 years ago

After upgrading all modules I found out that OAuth2Strategy callback just did't fire.

I've created this issue at StackOverflow

After downgrading to 1.5.0 from 1.6.1 the problem is completely gone.

Please, provide some more info on this problem and how to resolve it.

Regards

iohansson commented 2 years ago

@Number16BusShelter I had a similar issue. I've tried downgrading to 1.5.0 like you suggest but that didn't help. Found this https://github.com/nodejs/node/issues/42116 issue in the node repo, downgraded to 16.3.0 and it worked like a charm without any errors. I'm using ESM and apparently they broke something in 16.4+. Of course, downgrading node is not the best option, I'll investigate further when I have time.

lcdss commented 2 years ago

I had a similar problem this week after upgrading to node v18, where this strategy stopped working. I spent a few hours until I tried v16 and the authentication start working again.

The error is the following:

InternalOAuthError: Failed to obtain access token
    at OAuth2Strategy._createOAuthError (/mnt/Shared/Code/my-project/api/node_modules/passport-oauth2/lib/strategy.js:423:17)
    at /mnt/Shared/Code/my-project/api/node_modules/passport-oauth2/lib/strategy.js:177:45
    at /mnt/Shared/Code/my-project/api/node_modules/oauth/lib/oauth2.js:191:18
    at ClientRequest.<anonymous> (/mnt/Shared/Code/my-project/api/node_modules/oauth/lib/oauth2.js:162:5)
    at ClientRequest.emit (node:events:537:28)
    at ClientRequest.emit (node:domain:482:12)
    at Socket.socketErrorListener (node:_http_client:465:9)
    at Socket.emit (node:events:537:28)
    at Socket.emit (node:domain:482:12)
    at emitErrorNT (node:internal/streams/destroy:151:8) {
  oauthError: Error: connect ECONNREFUSED ::1:8000
      at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1237:16) {
    errno: -111,
    code: 'ECONNREFUSED',
    syscall: 'connect',
    address: '::1',
    port: 8000
  }
}

At http://localhost:8000 was the oauth2 server (Laravel Passport).

hdmr25 commented 2 years ago

Hi, i have the same problem, i use v16.14.0 and the oauth library with 0.9.15. Is the problem also related to the version or are there any update and would a downgrade of the version help?