ladjs / supertest

🕷 Super-agent driven library for testing node.js HTTP servers using a fluent API. Maintained for @forwardemail, @ladjs, @spamscanner, @breejs, @cabinjs, and @lassjs.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot authenticate a POST request with 'x-www-form-urlencoded'

satabdisikdar opened this issue · comments

Code I am using
supertest(app).post(endpoint).type('form').send(authToken).expect(200).then((response)=>{ console.log(response.body.access_token); });

authToken data passed is-

let authToken = { grant_type:password username:{{email}} password:{{password}} audience:{{auth0_audience}} client_id:{{auth0_client_id}} };

I get 401 unauthorized.

This is not an issue with supertest nor superagent, it is an issue with your usage or the endpoint/server.

Try with curl to see that it's not an issue with this package.