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

TokenError: The client_id and/or client_secret passed are incorrect. #77

Open
hh54188 opened this issue Aug 3, 2020 · 0 comments
Open

Comments

@hh54188
Copy link

hh54188 commented Aug 3, 2020

I write app demo just like the example code:

passport.use(new GitHubStrategy({
        clientID: process.env.GITHUB_CLIENT_ID as string,
        clientSecret: process.env.GITHUB_CLIENT_SECRET as string,
        callbackURL: "http://127.0.0.1:3000/auth/github/callback"
    },
    function(accessToken, refreshToken, profile, callback) {
        return callback(null, {});
    }
));

passport.serializeUser((user, done) => {
    console.log('serializeUser');
    done(null, 1);
});

passport.deserializeUser((id, done) => {
    console.log('deserializeUser');
    done(null, {});
});

// app.use(helmet());
// app.use(cors());
app.use(express.json());
app.use(session({
    store: new MemoryStore({
        checkPeriod: 86400000 // prune expired entries every 24h
    }),
    secret: process.env.SESSION_SECRECT as string,
    resave: false,
    saveUninitialized: false,
    cookie: {
        secure: true,
        httpOnly: true,
    }
}));
app.use(express.urlencoded({ extended: true }));
app.use(express.json());
app.use(passport.initialize());
app.use(passport.session());

app.get('/auth/github',
    passport.authenticate('github'));

app.get('/auth/github/callback',
    passport.authenticate('github', { failureRedirect: '/login_failed' }),
    function(req, res) {
        res.redirect('/');
    });

however, when I try to login, I get the error:

TokenError: The client_id and/or client_secret passed are incorrect.
    at Strategy.OAuth2Strategy.parseErrorResponse (/Users/guangyi.li/Desktop/side-project/tenet/node_modules/passport-oauth2/lib/strategy.js:358:12)
    at Strategy.OAuth2Strategy._createOAuthError (/Users/guangyi.li/Desktop/side-project/tenet/node_modules/passport-oauth2/lib/strategy.js:405:16)
    at /Users/guangyi.li/Desktop/side-project/tenet/node_modules/passport-oauth2/lib/strategy.js:175:45
    at /Users/guangyi.li/Desktop/side-project/tenet/node_modules/passport-github/lib/strategy.js:79:16
    at /Users/guangyi.li/Desktop/side-project/tenet/node_modules/oauth/lib/oauth2.js:209:7
    at passBackControl (/Users/guangyi.li/Desktop/side-project/tenet/node_modules/oauth/lib/oauth2.js:134:9)
    at IncomingMessage.<anonymous> (/Users/guangyi.li/Desktop/side-project/tenet/node_modules/oauth/lib/oauth2.js:157:7)
    at IncomingMessage.emit (events.js:327:22)
    at IncomingMessage.EventEmitter.emit (domain.js:482:12)
    at endReadableNT (_stream_readable.js:1221:12)

It seem the issue happened here, the returned access token is undefined:

Snip20200803_12

but I found my github oauth already have one user, and the user also have the oauth app authorized. So what's wrong with my code ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant