Hi @grehkemper!
Welcome to the community!
In regards to your issue, what I would suggest in this instance is to obtain the authorization token via a pre-request script, and then saving that token as an environment variable, such as {{authToken}}.
Then using that in your form-urlencoded payload to your service, by just adding the key value pair (token / {{authToken}}.
Not sure how you need to format your request to obtain your token, but if it follows the OAuth 2.0 spec, something like so should work:
pm.sendRequest({
url: pm.variables.get("Auth_Url"),
method: 'POST',
header: {
'Accept': 'application/json',
'Content-Type': 'application/x-www-form-urlencoded',
'Authorization': pm.variables.get("Basic_Auth")
},
body: {
mode: 'urlencoded',
urlencoded: [
{key: "grant_type", value: "password", disabled: false},
{key: "username", value: pm.environment.get("OAUTH_USERNAME"), disabled: false},
{key: "password", value: pm.environment.get("OAUTH_PASSWORD"), disabled: false}
]
}
}
}, function (err, res) {
pm.environment.set("authToken", res.json().access_token);
pm.environment.set("OAuth_Timestamp", new Date());
// Set the ExpiresInTime variable to the time given in the response if it exists
if(res.json().expires_in){
expiresInTime = res.json().expires_in * 1000;
}
pm.environment.set("ExpiresInTime", expiresInTime);
});
Filling in the correct key value pairs above
*Obtained from: How to Automate OAuth2 Token Renewal in Postman | by Allen Helton | Medium
And
https://gist.github.com/madebysid/b57985b0649d3407a7aa9de1bd327990
Hope this helps!
Orest