luizkc / firebase-discord-oauth2-example

An example of how to setup Discord, or any external oAuth2 provider, with your Firebase app.
https://us-central1-discord-oauth-demo.cloudfunctions.net/api/login
MIT License
117 stars 14 forks source link

Failed to obtain access token #2

Closed OmarEMC closed 3 years ago

OmarEMC commented 4 years ago

When i access to /api/login an then it redirects me to /api/auth says Internal Server Error an the console:

InternalOAuthError: Failed to obtain access token
    at Strategy.OAuth2Strategy._createOAuthError (/srv/node_modules/passport-oauth2/lib/strategy.js:408:17)
    at /srv/node_modules/passport-oauth2/lib/strategy.js:175:45
    at /srv/node_modules/oauth/lib/oauth2.js:191:18
    at ClientRequest.<anonymous> (/srv/node_modules/oauth/lib/oauth2.js:162:5)
    at emitOne (events.js:116:13)
    at ClientRequest.emit (events.js:211:7)
    at TLSSocket.socketErrorListener (_http_client.js:401:9)
    at emitOne (events.js:116:13)
    at TLSSocket.emit (events.js:211:7)
    at emitErrorNT (internal/streams/destroy.js:66:8)

Any ideas?

Coolguy3289 commented 4 years ago

I'm getting the same error, any update on this getting fixed?

Coolguy3289 commented 4 years ago

I've updated all dependencies in the package.json and it has not resolved the issue, there's alterations to the code that will need to be made.

luizkc commented 3 years ago

Go into your Discord Developer Portal app settings and make sure the Redirect URI only points to the /api route, for example:

https://us-central1-<project-id>.cloudfunctions.net/api <-- Notice there is no /auth at the end as the read me previously stated.

I have updated the read me to prevent users from running into this error. If you still have issues after updating your Redirect URI please open another issue.

Sorry it took so long to respond, it is now working and tested with a live demo available.

Happy coding!