passport-oauth2
passport-oauth2 copied to clipboard
Callback not working
I'm trying to get an authorization code from eBay with passportjs-oauth2, but passport its not returning any data.
passport-config.js
const passport = require("passport");
const OAuth2Strategy = require("passport-oauth2").Strategy;
var authStrategy = new OAuth2Strategy(
{
authorizationURL: "https://auth.sandbox.ebay.com/oauth2/authorize?",
tokenURL: "https://api.sandbox.ebay.com/identity/v1/oauth2/token",
clientID: "client-id"
},
function(accessToken, refreshToken, profile, cb) {
console.log("Here!");
console.log(accessToken);
console.log(refreshToken);
console.log(profile);
cb(null, profile);
}
);
authStrategy.authorizationParams = function() {
return {
redirect_uri: "redirect-uri",
response_type: "code"
};
};
auth-route.js:
router.get("/redirect", passport.authenticate("ebay"), function(req, res) {
console.log("ebay");
console.log(req.params);
res.redirect("/");
});
And I get the following error: "request is missing a required parameter or malformed."
Any ideas? Edit: The URL does return the code I'm trying to get.
You are missing a bunch of stuff in
OAuth2Strategy(
{
authorizationURL: "https://auth.sandbox.ebay.com/oauth2/authorize?",
tokenURL: "https://api.sandbox.ebay.com/identity/v1/oauth2/token",
clientID: "client-id"
},
See https://github.com/sahat/hackathon-starter/blob/master/config/passport.js#L484 for a working example