node.js - Post call from Nodejs -


i trying authentication token api. request supposed like

post /oauth2/token http/1.1 host: mysageone.ca.sageone.com  client_id=4b64axxxxxxxxxx00710& client_secret=inumztxxxxxxxxxxhvhstrqwesh8tm9& code=12a0f9c12cxxxxxxxxxxxxxxx92a48cc1f237ead& grant_type=authorization_code& redirect_uri=https://myapp.com/auth/callback 

my current code keeps giving me status 400. have tried modify headers doesn't work. have tried make required parameters part of path using ?.

const http = require('http');     var options = {       hostname: 'app.sageone.com',       path: '/oauth2/token',       method: 'post',       headers: {         "client_id":"xxxxx",         "client_secret":"xxxxx",         "code":"xxxxxx",         "grant_type":"authorization_code",         "redirect_uri":"https://some link"         }     };     console.log('in users file point 2');     var req1 = http.request(options, (res1) => {       console.log('statuscode:', res1.statuscode);       console.log('headers:', res1.headers);       console.log('message',res1.statusmessage);       res1.on('data', (d) => {         res.json(d);       });     });      req1.on('error', (e) => {       console.error('error starts here',e);     });     req1.end(); }); 

looks me problem not node.js, use of sage one's api. the relevant documentation might solve problem.

from quick glance looks want send get not post, , should send parameters in url. here example url give:

https://www.sageone.com/oauth2/auth?response_type=code&client_id=4b64axxxxxxxxxx00710&redirect_uri=https://myapp.com/auth/callback


&scope=full_access

i've never used sage 1 before, match experience other oauth apis.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -