I am working on Node.js in which I am using superagent to call oauth token generation request and I am manually parsing a response from which I am extracting access_token, refresh_token, token_type, expires_in,etc.
below is the snippet for oauth token generation via superagent call
superagent
.post('https://myapi.com/oauth_token.do')
.proxy(proxy)
.type('form')
.send({grant_type: 'password' })
.send({client_id: 'client-id-value' })
.send({client_secret: 'client-secreat-value' })
.send({username: 'user' })
.send({password: 'pass' })
.set('Accept', 'application/json')
.end(function(err, res){
if (err || !res.ok) {
// error handling..
} else {
// response parsing..
});
I am looking for the node.js module which will take care of oauth token generation. Is there any node js module for the same ?
If possible could you please share the sample as well.
Thanks.