Compute OAuth signature for NetSuite restart using bash

I am currently trying to create an OAuth signature for my curl request header. This indicates a restart of NetSuite. The resources on the web are either inconclusive or too high for my understanding / lack of examples. How do I calculate the value oauth_signature

for my query?

Below is my request with credentials:

curl --request GET \
  --url 'https://rest.na1.netsuite.com/app/site/hosting/restlet.nl?script=foo&deploy=bar' \
  --header 'Authorization: OAuth realm="'"$realm"'",oauth_consumer_key="'"$oauth_consumer_key"'",oauth_token="'"$oauth_token"'",oauth_signature_method="HMAC-SHA1",oauth_timestamp="'"$(OAuth_timestamp)"'",oauth_nonce="'"$(OAuth_nonce)"'",oauth_version="1.0",oauth_signature="'"$(OAuth_signature)"'"' \
  --header 'cache-control: no-cache' \
  --header 'content-type: application/json' \
 | jq

      

Below is a list of parameters that I pass for readability:

params=(
    oauth_consumer_key='foo'
    oauth_signature_method='HMAC-SHA1'
    oauth_version='1.0'
    oauth_nonce=$(OAuth_nonce)
    oauth_timestamp=$(OAuth_timestamp)
    oauth_token='tokenfoo'
    realm='4478811'
)

      

I create timestamp and nonce like this:

OAuth_nonce () {
    md5 <<< "$RANDOM-$(date +%s.%N)" | cut -d' ' -f 1
}

OAuth_timestamp () {
    echo "$(date +%s)"
}

      

I got most of my resources from https://github.com/livibetter-backup/bash-oauth but no docs exist, examples are bad and the library itself doesn't seem to work when I tested the functions.

All of the values ​​I use in the script (passed by asserted bash +x

) work when running in Postman, but I can't figure out the value oauth_signature

outside of it.

How do I create a function oauth_signature

with which I can return a valid signature? What parameters do I need to pass in order to calculate this function correctly? Is it possible or possible to generate, perhaps using perl or python?

+3


source to share





All Articles