Open In App

How to add Bearer Token authentication in Postman ?

Last Updated : 27 Dec, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

Postman is a crucial platform for developers, aiding in API testing, creation, and modification. APIs support various website features, such as user registration and login. For secure actions like changing passwords, Bearer Token Authentication is used. Upon login, the server issues a token, acting as proof of authentication. To access protected features, users send this token with their requests, validating their logged-in status through Bearer Token Authentication.

We will discuss two ways to add Bearer token in Postman:

What is Bearer Token authentication?

  • Bearer token authentication is used to verify login in services requiring authentication, generating a cryptographic string on the server for users.
  • Postman is used to test APIs, including those for real-world authentication, using Bearer Token Authentication.
  • To test a password change API, log in using the API designed for login, which returns a token proving the user’s authentication.

login

Now after login, we need to change the password. Now for changing password, we designed our API such that it takes a new password and changes the the previous password with the new password.
But we need to prove that we are already logged In. So for that, we will send Bearer Token with the request of changing password and we will send that token as a Bearer Token which we got on login .

In Authorization Section:

Steps to be followed to send bearer token along with new password-

  • Go to the Authorization Section
  • Find the dropdown in front of the type
  • In that dropdown select Bearer Token
  • Paste the Bearer token in the box on the right side
  • Now send the request after writing the password in the “raw” section

Output:

password_change_authorization

In Header Section:

Bearer Token is sent from front end in the header of the request. In the request, we put Bearer Token as a key-value pair, where “Authorization” will be the key and the “Bearer” Keyword followed by Bearer Token after a space as value.

Steps to be followed to send bearer token along with new password-

  • Go to Header Section
  • Check a key-value pair box to include that key-value pair
  • Put “Authorization” in the key
  • In value write “Bearer” then give a space
  • After giving space paste your Bearer Token
  • Now send the request after writing the password in the “raw” section

Output:

password_change_header

Conclusion:

Hence the purpose of Bearer Token authentication in Postman is to verify legitmitacy of the request. It helps in reducing the risk of unauthorized access and dangerous security breaches. It also increase developers efficiency during the development and testing phase because bearer token authentication works in the same way as the authentication in real world application works.


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads