How to access inherited authorization in request`s pre-req. script?

When using oAuth 2.0 Authorization on a request…
image
…you can easily access the accessToken from the request via

pm.request.auth.oauth2.get('accessToken')

However, when you use the “inherit auth from parent” as authorization…
image
…you cannot.

I’ve already tried…

pm.collectionVariables.auth.oauth2.get('accessToken');

… since the oAuth 2.0 authorization is set up in the collection, but also this won´t work.

Similar threads i found to this topic - but no solution to the problem is given:
Reading Authorization header in pre-request script - Help - Postman
Determining auth type in a pre-request script - Help - Postman

1 Like
  1. Make the authorization call
  2. In the Test tab, extract the token and store it as a collection variable.
  3. At the collection level, in the authorization tab, set the authorization as the collection variable set in the authorization call.

Then all other requests in the collection can inherit from the parent - collection

The huge benefit of using the oAuth 2.0 Authorization Feature of Postman is to switch between multiple sessions via the “Manage Token” dropdown without having to re-login. Also you can make use of the “auto-refreh token” feature that way. By switching between sessions the “tests” tab is not executed.
When setting up a manual authorization request you loose the benefit described above.

So thanks for the hint, but this does not help me that concern.