0
0
Postmantesting~5 mins

Inheriting auth from collection in Postman

Choose your learning style9 modes available
Introduction

Inheriting auth from collection helps you avoid repeating login details for every request. It saves time and keeps your requests organized.

When you have many API requests that use the same login or token.
When you want to update your login details once and have all requests use the new info.
When you share a collection with others and want them to use the same authentication setup.
When testing APIs that require the same security method across multiple endpoints.
Syntax
Postman
1. Set authentication at the collection level in Postman.
2. In individual requests, choose 'Inherit auth from parent'.
Authentication settings include types like Bearer Token, Basic Auth, API Key, etc.
If a request has its own auth set, it overrides the collection's auth.
Examples
The request uses the Bearer Token 'abc123' from the collection automatically.
Postman
Collection Auth: Bearer Token = 'abc123'
Request Auth: Inherit auth from parent
The request uses the Basic Auth credentials set at the collection level.
Postman
Collection Auth: Basic Auth (username: user, password: pass)
Request Auth: Inherit auth from parent
The request sends the API Key header automatically from the collection.
Postman
Collection Auth: API Key in header 'x-api-key' = 'key123'
Request Auth: Inherit auth from parent
Sample Program

This setup shows how a request uses the collection's Bearer Token without setting it again.

Postman
1. Create a collection named 'My API Tests'.
2. Set collection auth to Bearer Token with value 'token123'.
3. Add a request 'Get User' with auth set to 'Inherit auth from parent'.
4. Send the request to an API that requires the Bearer Token.
5. The request will include the token 'token123' automatically.
OutputSuccess
Important Notes

Remember, if you set auth on a request, it will ignore the collection's auth.

Inheriting auth keeps your requests cleaner and easier to manage.

Summary

Inheriting auth means requests use the collection's login info automatically.

This saves time and avoids repeating the same details in every request.

It helps keep your API tests organized and easy to update.