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

Getting Unauthorised while using it #18

Open
Viraz04 opened this issue Feb 20, 2020 · 2 comments
Open

Getting Unauthorised while using it #18

Viraz04 opened this issue Feb 20, 2020 · 2 comments

Comments

@Viraz04
Copy link

Viraz04 commented Feb 20, 2020

Hi,
This is the code i am using, funny thing is the content i am trying to print in console isn't even prining, and i get Unauthorized returned.
passport.use(new ClientPasswordStrategy(
function(clientId, clientSecret, done) {
console.log("here")
console.log(clientId)
console.log(clientSecret)
db.clients.findByClientId(clientId, function (err, client) {
if (err) { return done(err); }
if (!client) { return done(null, false); }
if (client.clientSecret != clientSecret) { return done(null, false); }
return done(null, client);
});
}
))
these are the params i am sending,
http://localhost:3000/oauth/token?grant_type=authorization_code&code=xwOnUymH0vexcMzd&redirect_uri=http://localhost:3000/login&client_id=abc123&client_secret=ssh-secret
tried sending in form data and in body, am i doing something wrong, please help i am suck on this.

@ricaragao
Copy link

ricaragao commented Feb 17, 2021

@Viraz04 , did you solve your problem? I'm with same problem here.

@ricaragao
Copy link

I solved the problem. I needed to use body-parser before passport.initialize().

Like this example:

var session = require("express-session"),
    bodyParser = require("body-parser");

app.use(express.static("public"));
app.use(session({ secret: "cats" }));
app.use(bodyParser.urlencoded({ extended: false }));
app.use(passport.initialize());
app.use(passport.session());

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

2 participants