How to mimic oAuth authentication on a Postman mock server

Hi,

First of, I scoured the net as well as this forum for an answer or a hint. Unfortunately, I came up empty.

I’ve got an API collection for which I had set up a Postman mock server. The actual dev API makes use of oAuth 2 authentication for some of the endpoint calls.

I have two environments set up, one for the dev API environment and the other for the mock server. This allows me to switch the collection, for testing purposes, between the two environments. This works great. The problem is that the actual dev API makes use of aOuth 2 for authentication. For this reason, if I switch the environment to the mock server, the same call fails with a 401 Unauthorized error. Is there some way to overcome this on the mock server? In other words: how to mimic oAuth authentication on a Postman mock server?

Thank you in advance.

Images that may help to understand the question

Response from call against actual dev API

Response when doing the same call against the Postman mock server

It seems that I’ve been barking up the wrong tree. I found that with one of the other endpoint calls on the mock server, even though oAuth2 authentication is enabled on the call, I still receive a valid response from the mock server. It seems that on the mock server, the fact that the call “tries” to do oAuth authentication is simply ignored. This is great because it means that against the dev environment oAuth 2 is correctly applied but against the mock server it is ignored.

This would mean that the call that I originally referred to on this thread, the one that returns the 401 error, is actually returning the 401 error using an example saved on the mock server, not because of oAuth authentication failure.

I’m going to flag this thread as solved so that others that have the same question as what I had, may learn from my findings.

1 Like