Skip to content

Instantly share code, notes, and snippets.

@jonathanbarton
Created March 29, 2016 21:58
Show Gist options
  • Save jonathanbarton/42facc78db71932172fe295a9c262bf0 to your computer and use it in GitHub Desktop.
Save jonathanbarton/42facc78db71932172fe295a9c262bf0 to your computer and use it in GitHub Desktop.
weird_request_buffer
function authenticate(req, res) {
let options = {
method: 'POST',
url: 'http://connected-qa.cdiapps.com/api/v0.1/session',
headers: {
'content-type': 'application/json',
'accept': 'application/json',
'accept-encoding': 'gzip, deflate',
'accept-language': 'en-US,en;q=0.8,ja;q=0.6'
},
data: {username:"DLE", password: "testing123"}
};
let oauthConfig = oauth({
consumer: {
public: 'muBZPpFoD4ooNq5I',
secret: 'wHYE4xFCYnY4HyZZ'
},
signature_method: 'HMAC-SHA1'
});
let headers = oauthConfig.toHeader(oauthConfig.authorize(options));
headers = Object.assign(headers, options.headers);
let body = [];
let reqObject = request({
url: options.url,
method: options.method,
headers: headers,
json: options.data
}, function(error, response, body) {
//getting 401 error and I need to parse the response body here. body seems to be a buffer...
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment