In Postman I have the following configuration:
I have Basic Auth
permission for my collection.
I have an Admin User
environment. In this environment I have username
and password
.
When I run my requests, the Admin user
logs in and the request is sent.
I want to create an Anonymous user
environment and try to access my requests without authorization (No Auth).
How do I specify an authorization type for a specific environment?
What I would like to do is in the "Pre-Request Scripts" check if the environment is equal to anonymous user
and if so, do not login (using No Auth
) !
More generally, I would like to test that my requests return an HTTP 401 status if I am not connected.
Any help is welcome !
You cannot set it for a specific environment but can change it from pre reqeust script
in postman you can change all request related details using pm.request object . The authroization scheme is in the pm.request.auth
so in your case you can do something like this in your pre request script:
this will set auth to undefined if use is Anonymous else the default one