I am currently trying to implement the Uber API and am in the process of trying to get an access token for a user. The tutorial they provide is what I am basing this on (except using Node instead of Python): https://developer.uber.com/v1/tutorials/
The initial authorization get request is successful (step 1), but upon redirect and sending the POST request to receive an access token, I am unable to properly format the request to match their specifications. The NPM package I am using for HTTP requests is request (https://www.npmjs.org/package/request)
The response I get is "unsupported_grant_type", I have been unable to find any other SO questions regarding this issue so I would appreciate any suggestions to how I can properly format this request to successfully authorize an Uber user.
Thanks
router.get('/uber', function(req,res,next){
var url = "https://login.uber.com/oauth/authorize?response_type=code&client_id=" + encodeURIComponent(auth.uber.ClientID);
res.redirect(url);
})
router.get('/ubercallback', function(req,res,next){
params = {
'redirect_uri' : '/ubercallback',
'code' : req.query.code,
'grant_type' : 'authorization_code'
};
request({
uri: 'https://login.uber.com/oauth/token',
method: "POST",
auth : {
'user' : auth.uber.ClientID,
'password' : auth.uber.ClientSecret
},
data : {
'redirect_uri' : '/ubercallback',
'code' : req.query.code,
'grant_type' : 'authorization_code'
},
timeout: 10000,
followRedirect: true,
maxRedirects: 10
}, function(error, response, body) {
console.log(body);
});
res.redirect('/');
})