Estoy intentando utilizar la estrategia OAuth2 para Passport JS junto con Express (4).
Después de que me redireccioné para iniciar sesión, me lleva con éxito a mi url de devolución de llamada, momento en el que recibo el siguiente error:
TokenError: Invalid client or client credentials
at OAuth2Strategy.parseErrorResponse (/www/az-avatarz-server/node_modules/passport-oauth/node_modules/passport-oauth2/lib/strategy.js:298:12)
at OAuth2Strategy._createOAuthError (/www/az-avatarz-server/node_modules/passport-oauth/node_modules/passport-oauth2/lib/strategy.js:345:16)
at /www/az-avatarz-server/node_modules/passport-oauth/node_modules/passport-oauth2/lib/strategy.js:171:43
at /www/az-avatarz-server/node_modules/passport-oauth/node_modules/passport-oauth2/node_modules/oauth/lib/oauth2.js:177:18 at passBackControl (/www/az-avatarz-server/node_modules/passport-oauth/node_modules/passport-oauth2/node_modules/oauth/lib/oauth2.js:124:9)
at IncomingMessage.<anonymous> (/www/az-avatarz-server/node_modules/passport-oauth/node_modules/passport-oauth2/node_modules/oauth/lib/oauth2.js:143:7)
at IncomingMessage.EventEmitter.emit (events.js:117:20)
at _stream_readable.js:919:16
at process._tickDomainCallback (node.js:463:13)
La configuración de mi pasaporte es la siguiente:
passport.use("avatarz", new OAuth2Strategy({
authorizationURL: authorizationURL,
tokenURL: tokenURL,
clientID: clientID,
clientSecret: clientSecret,
callbackURL: callbackURL
},
function (accessToken, refreshToken, profile, done) {
User.find({
prid: profile.prid
}, function (error, user) {
if (error) {
return done(error);
}
if (user) {
return done(null, user);
}
else {
done(error);
}
});
}
));
Y mis rutas son las siguientes:
app.get("/authentication/provider", passport.authenticate("avatarz"));
app.get("/", passport.authenticate("avatarz", { failureRedirect: "/authentication/provider" }),
function (req, res) {
res.sendfile("./public/index.html");
});
Cualquier ayuda / consejo sería muy apreciado!
Respuestas
0 para la respuesta № 1Asegúrate de haber activado la API de Google+ en: https://console.developers.google.com