Newman command not processing environment variable and display NULL value in cmd

I am sending a POST request to

https://login.xyz.com/zyz/authorize

Output of this request in Response Body is HTML having access_token.

In Tests, I have added script to fetch the

access_token

from Response Body. When I run POST request in Postman using collection runner it works fine (signifying that test script is working in postman) and Postman Console displays the access token value (which I have added for debugging). But when I run it using newman command, it shows NULL .

That is, access token fetched and passed to environment variable is not processed by Newman hence it passes NULL value during runtime.

Does anybody have idea how to make newman read environment variable value which is set during runtime ?

It seems that newman is unable to store variables due to -

  1. POST request to https://login.xyz.com/zyz/authorize involves redirect requests
  2. Redirect requests works fine in POSTMAN app i.e. there is no trouble in authorizing in between redirect requests
  3. Whereas in newman, I am getting ‘Sign in to your account’ message in printed output body response