Reading Authorization header in pre-request script

Hello, I set up collection-level OAuth2 authentification with bearer token. This works well but I would like to log the decoded token to the console in a pre-request script in order to facilitate debugging claims issues etc. No issue decoding a token, however, I can’t seem to access it.

pm.request.auth is undefined since authentication is inherited, the various headers related properties/methods as well since, again, I don’t set any headers manually.

How can I do this?

Thank you!

@tha-dude I have not tried this but got a reference to similar type of question within the community.

I hope these will help you in some way.

Hello, thank you for the response however this does not work when the authentication is inherited from the collection for instance. pm.request.auth is not defined in that case.

How can I programatically read the authentication credentials from a request before the request is made?

1 Like