nzaleski
06/30/2020, 12:04 AMoauth-signature
can use sha-256
. What library should I use to create the signature?
Everything I see it looks like the token is generated through the service on the call. Should the library create the handle tokenization or should I be passing it in manually to create the signature?
const oauthSignature = require('oauth-signature')
const NonceGenerator = require('a-nonce-generator')
const https = require('https')
const nonce = new NonceGenerator().generate()
const httpMethod = 'GET'
const url = '<https://9999999-sb1.suitetalk.api.netsuite.com/services/rest/record/v1/salesOrder/3481015>'
const parameters = {
oauth_consumer_key: "7092e7fae232904dddccnn2348*88qencenb12452eda85d0302",
oauth_token: "c676fc73fceb8fsdmfm32m42342371230b46dcb60cb",
oauth_nonce: nonce.toString(),
oauth_timestamp: Date.now().toString(),
oauth_signature_method: 'HMAC-SHA256',
oauth_version: '1.0'
}
const consumerSecret = "7546ffsdfs06c9716sd23324w8a976qw5604ea954a6wqewewef316faa0ee9f8b96awqe"
const tokenSecret = "f70c22482591dsfsdffd4d17c9f86223cff86b97a3243236a2c9c82af1c1"
// generates a BASE64 encode HMAC-SHA1 hash
const signature = oauthSignature.generate(
httpMethod,
url,
parameters,
consumerSecret,
tokenSecret,
{ encodeSignature: false }
)
// console.log(encodedSignature)
// console.log(signature)
// console.log(oauth)
const oAuthString = `OAuth realm="9999999_SB1", oauth_consumer_key="7092e7fae232904dddccnn2348*88qencenb12452eda85d0302", oauth_token="c676fc73fceb8fsdmfm32m42342371230b46dcb60cb", oauth_signature_method="HMAC-SHA256",oauth_timestamp="${parameters.oauth_timestamp}", oauth_nonce="${parameters.oauth_nonce}", oauth_version="1.0", oauth_signature="${encodedSignature}"`
console.log(oAuthString)
https.get("<https://9999999-sb1.suitetalk.api.netsuite.com/services/rest/record/v1/salesOrder/3481015>", {
headers: {
"Authorization": oAuthString.toString()
}
},(res) => {
console.log('statusCode:', res.statusCode);
console.log('headers:', res.headers);
res.on('data', (d) => {
process.stdout.write(d);
});
}).on('error', (e) => {
console.error(e);
});
battk
06/30/2020, 12:06 AMnzaleski
06/30/2020, 12:09 AMbattk
06/30/2020, 12:11 AMbattk
06/30/2020, 12:11 AMmichoel
06/30/2020, 12:20 AMnzaleski
06/30/2020, 12:26 AMmichoel
06/30/2020, 12:26 AMnzaleski
07/01/2020, 7:53 PMoauth-1.0a