nicholastay / passport-discord

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

InternalOAuthError: Failed to fetch the user profile. #7

Closed kashalls closed 4 years ago

kashalls commented 6 years ago

I seem to be coming across this a lot more often than usual. The full error: 0|Sistine | InternalOAuthError: Failed to fetch the user profile. (status: 401 data: {"code": 0, "message": "401: Unauthorized"}) 0|Sistine | at /home/jordan/Sistine/node_modules/passport-discord/lib/strategy.js:65:25 0|Sistine | at passBackControl (/home/jordan/Sistine/node_modules/oauth/lib/oauth2.js:132:9) 0|Sistine | at IncomingMessage.<anonymous> (/home/jordan/Sistine/node_modules/oauth/lib/oauth2.js:157:7) 0|Sistine | at emitNone (events.js:111:20) 0|Sistine | at IncomingMessage.emit (events.js:208:7) 0|Sistine | at endReadableNT (_stream_readable.js:1056:12) 0|Sistine | at _combinedTickCallback (internal/process/next_tick.js:138:11) 0|Sistine | at process._tickDomainCallback (internal/process/next_tick.js:218:9)

My code: ` const passport = require('passport'); const { Strategy } = require('passport-discord');

    passport.use(new Strategy({
        clientID: client.user.id,
        clientSecret: dashboard.clientSecret,
        callbackURL: dashboard.callbackURL,
        scope: ['identify', 'guilds']
    },
    (accessToken, refreshToken, profile, done) => {
        process.nextTick(() => done(null, profile));
    }));`
Xzandro commented 4 years ago

I think this happens if a user hits the Authorize button on the Discord consent window multiple times, while the first authorize attempts is still loading. I don't have a solution to this tho. Did you find a fix or workaround for it?

kashalls commented 4 years ago

This was long patched by discord I believe. I don't remember when they fixed it.

cheslin23t commented 3 years ago

not patched, got the same err

Morb0 commented 3 years ago

Same You need the "identify" scope to work