Authorization using the same set of creds being set in the environment works when auth is being done through Postman interface but not with the pre-request script.
Using this through Postman interface and it works:
What details are you seeing in the Postman Console when this async request is made? What status code is this returning? Is this returning the expected JSON response?
If you open the Postman Console, you will see that request being sent - Clicking on this will display the data (URL, Headers, Bodies, etc.).
Is that giving you any clues about anything the request that might not look right? The grant_type in the helper is also different to what you are using in the script.
I can’t see what you have in front of you so I’m just making suggestions at this point.
At which part of the process are you getting that error?
That looks like the API is responding with something. Therefore the issue is with what you are sending which we won’t be able to help with without an API specification and more details. Perhaps this is a question for the Flytnow support team.
It is not always possible to automate all OAuth2.0 grant types. The Postman Authorization helpers are doing a lot of work in the background, and includes opening a browser so you can pass the interactive parts of the login.
Are you actually testing the login process, or do you just want to test the application you hit after authentication? In which case I would recommend reading the API specification and seeing if you can indeed set it to use client credentials for authorization while you do your API testing, and then set it back to Authorization code for production. This will be down to the options for registering your application within Flytnow.