So thanks to the help of super below and a bit more of digging I was able to sort out the missing bit. Also credit goes to AsianCaptainKirk who had done some digging prior to this and has a post and shortcut up on Reddit on how to do this. I will attach a screenshot to clarify but the missing piece from supers suggestion was a second header named Content-Type that had a value of application/x-www-form-urlencoded.
I assume it’s similar to doing a x-callback but adding the extra encoding to the url/header that was needed along with the encoding of the client ID and secret.
I will use Reddit as an example and because it’s a popular site that takes this approach. I was curious about how to use API or regular login fields to login to sites via shortcuts or JS. I have figured out how to do this in a limited way by using get url contents in shortcuts to do GET, POST and others and the same in JS by using multipart loads on a POST request.
In the case of a site like Reddit it seems to do this in basically two stages. I am limited to doing it as a grant type of password as I do not have my own server to complete a authenticate request via API. In the grant password option they list this script as a example
reddit@reddit-VirtualBox:~$ curl -X POST -d ‘grant_type=password&username=reddit_bot&password=snoo’ --user ‘p-jcoLKBynTLew:gko_LXELoV07ZBNUXrvWZfzE3aI’ https://www.reddit.com/api/v1/access_token
I know to drop out anything before curl or cURL and I see it listed as a post. When I try to replicate that via shortcuts get url I get an error message saying unauthorized. I am not exactly clear how to translate that to JS in Scriptable either.
My understanding is that the API wants to do this in two parts. The first is a request to the base url to cover the grant type and username and password and a second to use the app id and secret id to authenticate and generate the token.
If anyone has any suggestions how to do this in JS via Scriptable or Shortcuts or has some ideas where I can read up to answer my own question I would love to hear it. I was wandering if some kind of x-callback could work in shortcuts? I don’t know totally lost here lol