nicholastay / passport-discord

Passport strategy for authentication with Discord (discordapp.com)
ISC License
172 stars 55 forks source link

TokenError #17

Open ghost opened 5 years ago

ghost commented 5 years ago

Whenever I go to /api/login/discord, it works normally and redirects me to the discord link. Once authorized, I get redirected to /api/discord/callback but with a TokenError.

TokenError at Strategy.OAuth2Strategy.parseErrorResponse ([Working Directory]\node_modules\passport-oauth2\lib\strategy.js:358:12) at Strategy.OAuth2Strategy._createOAuthError ([Working Directory]\node_modules\passport-oauth2\lib\strategy.js:405:16) at [Working Directory]\node_modules\passport-oauth2\lib\strategy.js:175:45 at [Working Directory]\node_modules\oauth\lib\oauth2.js:191:18 at passBackControl ([Working Directory]\node_modules\oauth\lib\oauth2.js:132:9) at IncomingMessage. ([Working Directory]\node_modules\oauth\lib\oauth2.js:157:7) at IncomingMessage.emit (events.js:202:15) at endReadableNT (_stream_readable.js:1129:12) at processTicksAndRejections (internal/process/next_tick.js:76:17)

Code here: https://pastebin.com/ji1fr5EF

reetou commented 5 years ago

Same.

ghost commented 5 years ago

Last update was a year ago, this probably broke due to updates. I might make a replacement module tbh.

PLASMAchicken commented 5 years ago

This still works fine for me are you sure you set the clientSecret: CLIENT_SECRET,?

ZE0TRON commented 5 years ago

After digging the source code I have found out that if you some parameters wrong to the strategy it gives you this error. Also the callback url should be a global url like https://example.com/discord/auth/ not like /discord/auth.

thrace19 commented 4 years ago

After digging the source code I have found out that if you some parameters wrong to the strategy it gives you this error. Also the callback url should be a global url like https://example.com/discord/auth/ not like /discord/auth.

Yeah, I faced the same issue if you enter any wrong parameter to the strategy it will fail.

ljosberinn commented 4 years ago

Also the callback url should be a global url like https://example.com/discord/auth/ not like /discord/auth.

Cannot confirm, works fine without a global url. However, can confirm that if you encounter this error, double check your token/secret and that they are properly set.

huss-a commented 3 years ago

Please make sure to double check your Client ID && Secret, because I didn't pay attention to them and spent an hour trying to debug a problem that was occuring because my secret was missing a hiphon 😐. Pain.

LingleDev commented 3 years ago

Even after checking all of the parameters to the Strategy it still does this for me.

Randomx24 commented 3 years ago

TokenError at Strategy.OAuth2Strategy.parseErrorResponse (/home/runner/botlistw-1/node_modules/passport-discord/node_modules/passport-oauth2/lib/strategy.js:358:12) at Strategy.OAuth2Strategy._createOAuthError (/home/runner/botlistw-1/node_modules/passport-discord/node_modules/passport-oauth2/lib/strategy.js:405:16) at /home/runner/botlistw-1/node_modules/passport-discord/node_modules/passport-oauth2/lib/strategy.js:175:45 at /home/runner/botlistw-1/node_modules/passport-discord/node_modules/oauth/lib/oauth2.js:191:18 at passBackControl (/home/runner/botlistw-1/node_modules/passport-discord/node_modules/oauth/lib/oauth2.js:132:9) at IncomingMessage.<anonymous> (/home/runner/botlistw-1/node_modules/passport-discord/node_modules/oauth/lib/oauth2.js:157:7) at IncomingMessage.emit (events.js:326:22) at endReadableNT (_stream_readable.js:1241:12) at processTicksAndRejections (internal/process/task_queues.js:84:21)

PLASMAchicken commented 3 years ago

Can you post a short & reproduceable code sample ( like on Stackoverflow )

mrsaifullah52 commented 2 years ago

After digging the source code I have found out that if you some parameters wrong to the strategy it gives you this error. Also the callback url should be a global url like https://example.com/discord/auth/ not like /discord/auth.

When I'm using the callback URL like this:

router.get( "/redirect", passport.authenticate("discord", { failureRedirect: "/" }), function (req, res) { res.redirect("/info"); } // auth success );

only then the error trigger, so is it safe to redirect the user without passport middleware?

i tried to check user login status with this method req.isAuthenticated(), its reponse is false

prbhanu commented 2 years ago

After digging the source code I have found out that if you some parameters wrong to the strategy it gives you this error. Also the callback url should be a global url like https://example.com/discord/auth/ not like /discord/auth.

Yeah, I faced the same issue if you enter any wrong parameter to the strategy it will fail. i still get the error

PLASMAchicken commented 2 years ago

i still get the error

https://stackoverflow.com/help/how-to-ask

You get the error because of user-error, your parameters are wrong can you provoide a minimal repoduceable sample code....?

benji4411 commented 1 year ago

I got this error, it was because i was using public key instead of client secret. I'm pretty dumb i know, but i'm sharing in case anyone is as dumb as me.

ManrajSaini commented 12 months ago

I got this error, it was because i was using public key instead of client secret. I'm pretty dumb i know, but i'm sharing in case anyone is as dumb as me.

Thanks benji4411, i also did the same thing 😂, it worked now.