question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Always return "missing credentials"

See original GitHub issue

This is my implementation with coffeescript and Express 4

passport.use new LocalStrategy
   usernameField:'emailAddress'
,(username,password,done) ->
   console.log('credentials passed to passport' + username + '' + password)

  User.findOne emailAddress:username,(err,user) ->
    if err then return done(err)
    if not user
      return done(null,false,message:'Incorrect data')
    bcrypt.compare password,user.password, (err,isMatch) ->
      if err then return done(err)
      if isMatch then return done(null,user)
      else return done(null,false,message:'Incorrect data')

#Authenticate user
app.post '/api/v1/auth/login',(req,res,next) ->
  passport.authenticate('local',(err,user,info) ->
    error = err or info
    if error then return res.status(400).json {user:null,state:'failure',error:error}
    req.logIn user,(err) ->
      if err then return res.status(400).json {user:null,state:'failure',error:err}
      res.status(200).json {user:req.user,state:'success'}
  ) req,res,next

I’m also using a linkedIn-strategy

I testing with an angular app and also with

 curl -v -d '{"emailAddress":"test@test.cl","password":"test"}' http://127.0.0.1:8070/api/v1/auth/login --trace-ascii /dev/stdout -H "Content-Type: application/json"

But I only get this

{"user":null,"state":"failure","error":{"message":"Missing credentials"}}

can you see the problem?

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:17 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
mansoor-omranicommented, May 21, 2020

My problem was that I was using bodyParser to parse request body as json:

app.use(bodyParser.json());

If you have an html form and are posting username/password to the server, you need to ask bodyparser to parse urlencoded body:

app.use(bodyParser.urlencoded({ extended: false }));

3reactions
abayosscommented, Jun 8, 2019

i do not know if it would be helpful to somebody but : i solved the same problem by checking the password input name , it had a capital P !

Read more comments on GitHub >

github_iconTop Results From Across the Web

passport js missing credentials - Stack Overflow
When I run this, i used console.log , output was { message: 'Missing credentials' } , which leads me to believe that the...
Read more >
Credentials are missing - Forum - Foglight - Quest Community
Hi,. I'm testing the foglight enterprise and in optimization gives an error "Failed - Credentials are missing". I create a lockbox and then...
Read more >
Solved: SharePoint Invalid/missing Credentials
... connection returning the message: "Data source credentials are missing. ... and the error message (particularly in the service) always is something a ......
Read more >
Access-Control-Allow-Credentials - HTTP - MDN Web Docs
Note that simple GET requests are not preflighted. So, if a request is made for a resource with credentials, and if this header...
Read more >
Missing Credentials" error on my login page using passportjs ...
Coding example for the question "Missing Credentials" error on my login page using ... Sending Push using node-apn always returns Invalid token (8) ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found