Replicate Authorization Oauth2 form tab into pre request script

I’m able to generate the client_credentials token with form provided by Postman on Authorization tab but I would like to replicate this behaviour on Pre Request Script so I can retrieve the token automatically and use it on every request that then will be executed by Newman.

image

But at this point I’m getting “Invalid token audience. Provided value [xxxx-xxxx…] does not match neither tenant configuration.”

Thanks for your post, and sorry we didn’t get to this sooner. This isn’t the experience we want for our users. This post might provide some insight into the structure of a pre-request script to get a token.

Since the post is a bit older, we’re closing it to make room for newer discussions.