Postman - Access Token Retrieval using Authorisation Code grant type

3.3k views Asked by At

I have set up a release pipeline to automatically deploy an API artefact to a particular domain, and as part of that pipeline I have introduced the execution of a postman collection via the Newman CLI, the ultimate goal that I want to achieve with this is a post-deployment "integration test".

My API is secured using Identity Server 4 and there is a client created that uses the grant type "authorisation_code"

I am able to manually create an access token through the "Get New Access Token" feature of Postman, but there doesn't seem to be a way to get a new token when running through the collection runner. Nor can I find a way to do this via the NewMan CLI thus these test responses come back as "401".

Does anybody know of a way to retrieve an authorisation code / access token within postman pre-request scripts or a way to ensure that an access token is requested when running through the collection runner or via Newman CLI?

BTW I don't mind supplying test creds through an environment file.

0

There are 0 answers