How to use POSTMAN to test OAuth 2.0 Web API

In the article, we will be using Postman to test OAuth 2.0 Web API


You can also use any other company's API which uses OAuth 2.0.


You can download and install POSTMAN from the official website


POSTMAN is a tool which can simplify API testing.


POSTMAN offers a simple user-friendly interface.


Once you open the application, you should see the main application window:


postman-oauth20.PNG

Example


- First, Go to POSTMAN


- Create a Collection named "TestOuth20API"


postman-oauth20_1.PNG

- Add a request to the TestOuth20API Collection


postman-oauth20_2.PNG

postman-oauth20_3.PNG

- Select the HTTP POST method


- Enter your request URL


Let's see what happens when we hit the secured endpoint without authorization:


postman-oauth20_4.PNG

Authentication error will occur and 400 Bad Request status will be returned. This means that this endpoint requires Authentication to access the resource.


We need to set up OAuth 2.0 authorization for testing API calls.


How to generate an access token using OAuth 2.0 in Postman?


- Next step would be to generate an access token in POSTMAN


- Fill your key-value pairs and click the Send button

postman-oauth20_5.PNG

You receive a JSON response containing the access token. The response has a status 200, so that the request is successful.


tags : how to use postman to test api, How to use POSTMAN with OAuth 2.0 Web API