Table of contents
1.
Introduction
2.
Authorization
3.
Authorization Vs Authentication
4.
Authorization using Postman
5.
Checking Authorization using Credentials 
6.
Authentication by Encoding
6.1.
Encoding through a Third Party
6.2.
Encoding through Postman
7.
Frequently Asked Questions
7.1.
What do you mean by 401 Authorization Error?
7.2.
How to fix Postman's 401 Unauthorized Error?
7.3.
What does the 403 error code mean?
8.
Conclusion
Last Updated: Mar 27, 2024

Authorizing Requests in Postman

Author Nidhi Kumari
0 upvote
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

Postman is a popular API platform. It has over 20 million+ users worldwide. Creating an API project is simple by using Postman. A project may contain several APIs, but only specific authorized users may have access to them. Authorization is verifying a user's eligibility to access the server. 

Authorizing Requests in Postman

In this article, we will learn about authorizing requests in postman. So without any further delay, let’s start.

Authorization

Protecting an API is very important. It includes two main processes:

  1. Authorization
  2. Authentication

 

Authorization is used by APIs that need to be secured. It is carried out to identify the user and determine whether they have the right to access a server resource. It provides two results to a user:

  1. Authorized: “✅You can access the data.”
  2. Not Authorized: “ERROR!!❌ You can’t access the data.”

 

In Postman, it is done using the  Authorization Tab, as shown below:

Authorization Tab

Now, let’s understand what Authentication is. 

Authorization Vs Authentication

Many of us live in confusion that authorization and authentication are the same, but this is not the case. These two terms are different and are closely related.

After authentication, authorization is granting or denying someone access to the resources.

In simple terms,

  1. Authentication: It checks Who you are.🔍
  2. Authorization: It checks What you can do.🔑

 

Authentication is done to verify a user's identity, whereas Authorization permits access to resources.

Authorization Vs Authentication

Authorization using Postman

📁 When a request is authorized, the identity of the client sending it is verified.

📁 The client's authorization to access and use the endpoint is also checked. 

📁 APIs employ authorization information to ensure that client requests for data access are secure.

📁 In Postman, there are various authorization types that you can utilise while building an API.

📁 When utilising a third-party API, you must ask the provider for any authorization information you need.

Let’s discuss the checking authorization in postman.

🧩 Step 1: Generate a Post request to use the GitHub Developer APIs using the endpoint https://postman-echo.com/basic-auth.

Echo request

 

🧩 Step 2: Choose the JSON format from the drop-down menu under the Body tab in Postman after clicking the raw option.

🧩 Step 3: Add the request body listed below.

{

    "name""Coding Ninjas"

}

Request body

 

🧩 Step 4: Click on the Send button.

After Sending the request, we will get the response as shown below:

Response

We will get a status code 401, which means we are Unauthorized to access the API.

Checking Authorization using Credentials 

🧩 Step 1: We will create a POST request again to check the authorization using credentials. Use https://postman-echo.com/basic-auth as endpoints.

🧩 Step 2: Go to the header. You will get a key, value, and description section.

🧩 Step 3: Add Authorization in the key section and add Basic Ninja: password as the value.

We are using Ninja as the username and password as the password.

Headers

 

🧩 Step 4: Click on the Send button.

After Sending the request, we will get status code 400 and bad request in response. We will get the answer as shown below:

Bad Request

Authentication by Encoding

We will learn Authentication by encoding using two methods:

🏆 Using a third-party website.

🏆 Using Authorization TYPE.

Encoding through a Third Party

Many websites are available, but we will discuss Base64 Decode and Encode. Follow the given steps to see the encoding process:

🧩 Step 1: Go to URL https://www.base64encode.org/.

BASE64

🧩 Step 2: In the edit box, type Postman: password.

🧩 Step 3: Click Encode. We can see the encoded value at the base.

Encode to base64

🧩 Step 4: Go back to the postman app, and in the value section, instead of postman: password, add the encoded data. Press the Send button.

We will see “authenticated: true” in our response section.

True Authentication

Encoding through Postman

We'll try to encode using Postman rather than using a third-party website.

🧩 Step 1: Remove the values from the key-value pair that we previously created.

🧩 Step 2: Select the Basic Auth in the Type dropdown of the Authorization tab.

Basic Auth

🧩 Step 3: Write postman in username and password in the password section.

🧩 Step 4: Click on the Send button.

We will find “authenticated: true” in our response section.

Frequently Asked Questions

What do you mean by 401 Authorization Error?

An HTTP status code problem known as the 401 Unauthorized Error denotes a client request that was delivered to a server but failed due to invalid authentication credentials. It could be displayed as HTTP error 401- Unauthorized, 401 Unauthorized, or Authorization required. It indicates that the request's authenticity was not possible.

How to fix Postman's 401 Unauthorized Error?

  • Verify that you typed the URL correctly. 
  • Ensure you have chosen the correct authorization type in Postman and checked the API documentation for the service you are attempting to access. 
  • Find a Sign in link on the service provider's page by visiting it. 
  • After entering your credentials, try the page once more.

What does the 403 error code mean?

The server understands the request but rejects it, as shown by the HTTP response status code 403 Forbidden. This status is comparable to 401, yet re-authenticating does not affect the 403 Forbidden status code.

Conclusion

We discuss authorizing requests with the postman in detail. We covered Authorization, Authentication, Credentials, and Authorizing by encoding.

We hope this blog has helped you. We recommend you to visit our articles on different topics of Postman, such as

 

You may also like our articles related to Web testing and APIs:

  • API
  • API Testing
  • Web Testing

 

If you liked our article, do upvote our article and help other ninjas grow.  You can refer to our Guided Path on Coding Ninjas Studio to upskill yourself in Data Structures and AlgorithmsCompetitive ProgrammingSystem Design, and many more!

Head over to our practice platform Coding Ninjas Studio to practice top problems, attempt mock tests, read interview experiences and interview bundles, follow guided paths for placement preparations, and much more!!

Happy Reading!!

Live masterclass