How to add Bearer Token authentication in Postman ? - GeeksforGeeks (2024)

Skip to content

How to add Bearer Token authentication in Postman ? - GeeksforGeeks (1)

Last Updated : 05 Aug, 2024

Suggest changes

Like Article

Like

Save

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:

Table of Content

  • In Authorization Section:
  • In Header Section:

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.

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:

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:

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.



How to add Bearer Token authentication in Postman ? - GeeksforGeeks (3)

GeeksforGeeks

How to add Bearer Token authentication in Postman ? - GeeksforGeeks (4)

Improve

Please Login to comment...

We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy

How to add Bearer Token authentication in Postman ? - GeeksforGeeks (5)

'); $('.spinner-loading-overlay').show(); jQuery.ajax({ url: writeApiUrl + 'create-improvement-post/?v=1', type: "POST", contentType: 'application/json; charset=utf-8', dataType: 'json', xhrFields: { withCredentials: true }, data: JSON.stringify({ gfg_id: post_id, check: true }), success:function(result) { jQuery.ajax({ url: writeApiUrl + 'suggestions/auth/' + `${post_id}/`, type: "GET", dataType: 'json', xhrFields: { withCredentials: true }, success: function (result) { $('.spinner-loading-overlay:eq(0)').remove(); var commentArray = result; if(commentArray === null || commentArray.length === 0) { // when no reason is availaible then user will redirected directly make the improvment. // call to api create-improvement-post $('body').append('

'); $('.spinner-loading-overlay').show(); jQuery.ajax({ url: writeApiUrl + 'create-improvement-post/?v=1', type: "POST", contentType: 'application/json; charset=utf-8', dataType: 'json', xhrFields: { withCredentials: true }, data: JSON.stringify({ gfg_id: post_id, }), success:function(result) { $('.spinner-loading-overlay:eq(0)').remove(); $('.improve-modal--overlay').hide(); $('.unlocked-status--improve-modal-content').css("display","none"); $('.create-improvement-redirection-to-write').attr('href',writeUrl + 'improve-post/' + `${result.id}` + '/', '_blank'); $('.create-improvement-redirection-to-write')[0].click(); }, error:function(e) { $('.spinner-loading-overlay:eq(0)').remove(); var result = e.responseJSON; if(result.detail.non_field_errors.length){ $('.improve-modal--improve-content .improve-modal--improve-content-modified').text(`${result.detail.non_field_errors}.`); jQuery('.improve-modal--overlay').show(); jQuery('.improve-modal--improvement').show(); $('.locked-status--impove-modal').css("display","block"); $('.unlocked-status--improve-modal-content').css("display","none"); $('.improve-modal--improvement').attr("status","locked"); $('.improvement-reason-modal').hide(); } }, }); return; } var improvement_reason_html = ""; for(var comment of commentArray) { // loop creating improvement reason list markup var comment_id = comment['id']; var comment_text = comment['suggestion']; improvement_reason_html += `

${comment_text}

`; } $('.improvement-reasons_wrapper').html(improvement_reason_html); $('.improvement-bottom-btn').html("Create Improvement"); $('.improve-modal--improvement').hide(); $('.improvement-reason-modal').show(); }, error: function(e){ $('.spinner-loading-overlay:eq(0)').remove(); // stop loader when ajax failed; }, }); }, error:function(e) { $('.spinner-loading-overlay:eq(0)').remove(); var result = e.responseJSON; if(result.detail.non_field_errors.length){ $('.improve-modal--improve-content .improve-modal--improve-content-modified').text(`${result.detail.non_field_errors}.`); jQuery('.improve-modal--overlay').show(); jQuery('.improve-modal--improvement').show(); $('.locked-status--impove-modal').css("display","block"); $('.unlocked-status--improve-modal-content').css("display","none"); $('.improve-modal--improvement').attr("status","locked"); $('.improvement-reason-modal').hide(); } }, }); } else { if(loginData && !loginData.isLoggedIn) { $('.improve-modal--overlay').hide(); if ($('.header-main__wrapper').find('.header-main__signup.login-modal-btn').length) { $('.header-main__wrapper').find('.header-main__signup.login-modal-btn').click(); } return; } } }); $('.left-arrow-icon_wrapper').on('click',function(){ if($('.improve-modal--suggestion').is(":visible")) $('.improve-modal--suggestion').hide(); else{ $('.improvement-reason-modal').hide(); } $('.improve-modal--improvement').show(); }); function loadScript(src, callback) { var script = document.createElement('script'); script.src = src; script.onload = callback; document.head.appendChild(script); } function suggestionCall() { var suggest_val = $.trim($("#suggestion-section-textarea").val()); var array_String= suggest_val.split(" ") var gCaptchaToken = $("#g-recaptcha-response-suggestion-form").val(); var error_msg = false; if(suggest_val != "" && array_String.length >=4){ if(suggest_val.length <= 2000){ var payload = { "gfg_post_id" : `${post_id}`, "suggestion" : `

${suggest_val}

`, } if(!loginData || !loginData.isLoggedIn) // User is not logged in payload["g-recaptcha-token"] = gCaptchaToken jQuery.ajax({ type:'post', url: "https://apiwrite.geeksforgeeks.org/suggestions/auth/create/", xhrFields: { withCredentials: true }, crossDomain: true, contentType:'application/json', data: JSON.stringify(payload), success:function(data) { jQuery('.spinner-loading-overlay:eq(0)').remove(); jQuery('#suggestion-section-textarea').val(""); jQuery('.suggest-bottom-btn').css("display","none"); // Update the modal content const modalSection = document.querySelector('.suggestion-modal-section'); modalSection.innerHTML = `

Thank You!

Your suggestions are valuable to us.

You can now also contribute to the GeeksforGeeks community by creating improvement and help your fellow geeks.

`; }, error:function(data) { jQuery('.spinner-loading-overlay:eq(0)').remove(); jQuery('#suggestion-modal-alert').html("Something went wrong."); jQuery('#suggestion-modal-alert').show(); error_msg = true; } }); } else{ jQuery('.spinner-loading-overlay:eq(0)').remove(); jQuery('#suggestion-modal-alert').html("Minimum 5 Words and Maximum Character limit is 2000."); jQuery('#suggestion-modal-alert').show(); jQuery('#suggestion-section-textarea').focus(); error_msg = true; } } else{ jQuery('.spinner-loading-overlay:eq(0)').remove(); jQuery('#suggestion-modal-alert').html("Enter atleast four words !"); jQuery('#suggestion-modal-alert').show(); jQuery('#suggestion-section-textarea').focus(); error_msg = true; } if(error_msg){ setTimeout(() => { jQuery('#suggestion-section-textarea').focus(); jQuery('#suggestion-modal-alert').hide(); }, 3000); } } document.querySelector('.suggest-bottom-btn').addEventListener('click', function(){ jQuery('body').append('

'); jQuery('.spinner-loading-overlay').show(); if(loginData && loginData.isLoggedIn) { suggestionCall(); return; } // load the captcha script and set the token loadScript('https://www.google.com/recaptcha/api.js?render=6LdMFNUZAAAAAIuRtzg0piOT-qXCbDF-iQiUi9KY',[], function() { setGoogleRecaptcha(); }); }); $('.improvement-bottom-btn.create-improvement-btn').click(function() { //create improvement button is clicked $('body').append('

'); $('.spinner-loading-overlay').show(); // send this option via create-improvement-post api jQuery.ajax({ url: writeApiUrl + 'create-improvement-post/?v=1', type: "POST", contentType: 'application/json; charset=utf-8', dataType: 'json', xhrFields: { withCredentials: true }, data: JSON.stringify({ gfg_id: post_id }), success:function(result) { $('.spinner-loading-overlay:eq(0)').remove(); $('.improve-modal--overlay').hide(); $('.improvement-reason-modal').hide(); $('.create-improvement-redirection-to-write').attr('href',writeUrl + 'improve-post/' + `${result.id}` + '/', '_blank'); $('.create-improvement-redirection-to-write')[0].click(); }, error:function(e) { $('.spinner-loading-overlay:eq(0)').remove(); var result = e.responseJSON; if(result.detail.non_field_errors.length){ $('.improve-modal--improve-content .improve-modal--improve-content-modified').text(`${result.detail.non_field_errors}.`); jQuery('.improve-modal--overlay').show(); jQuery('.improve-modal--improvement').show(); $('.locked-status--impove-modal').css("display","block"); $('.unlocked-status--improve-modal-content').css("display","none"); $('.improve-modal--improvement').attr("status","locked"); $('.improvement-reason-modal').hide(); } }, }); });

How to add Bearer Token authentication in Postman ? - GeeksforGeeks (2024)
Top Articles
Exodus vs Atomic: Price, Security & Features (2024)
Is BlueStacks Safe? A Comprehensive Security Analysis | VeePN Blog
Urist Mcenforcer
Hendersonville (Tennessee) – Travel guide at Wikivoyage
Merlot Aero Crew Portal
Stolen Touches Neva Altaj Read Online Free
Produzione mondiale di vino
ds. J.C. van Trigt - Lukas 23:42-43 - Preekaantekeningen
Southland Goldendoodles
Little Rock Arkansas Craigslist
What Is Njvpdi
Reddit Wisconsin Badgers Leaked
6001 Canadian Ct Orlando Fl
Evil Dead Rise Showtimes Near Regal Columbiana Grande
Shannon Dacombe
National Weather Service Denver Co Forecast
Tvtv.us Duluth Mn
8664751911
Craighead County Sheriff's Department
VERHUURD: Barentszstraat 12 in 'S-Gravenhage 2518 XG: Woonhuis.
1973 Coupe Comparo: HQ GTS 350 + XA Falcon GT + VH Charger E55 + Leyland Force 7V
Dtlr Duke St
Macu Heloc Rate
Powerschool Mcvsd
Pain Out Maxx Kratom
Marokko houdt honderden mensen tegen die illegaal grens met Spaanse stad Ceuta wilden oversteken
Firefly Festival Logan Iowa
Truck from Finland, used truck for sale from Finland
Duke Energy Anderson Operations Center
Missing 2023 Showtimes Near Grand Theatres - Bismarck
Transformers Movie Wiki
Kattis-Solutions
2024 Coachella Predictions
What Happened To Father Anthony Mary Ewtn
Bt33Nhn
Truis Bank Near Me
Craigslist Albany Ny Garage Sales
Indiana Immediate Care.webpay.md
Texas Baseball Officially Releases 2023 Schedule
T&J Agnes Theaters
Bismarck Mandan Mugshots
The Minneapolis Journal from Minneapolis, Minnesota
Craigslist Tulsa Ok Farm And Garden
Fifty Shades Of Gray 123Movies
Emily Browning Fansite
Www Craigslist Com Atlanta Ga
Elven Steel Ore Sun Haven
Pickwick Electric Power Outage
Maurices Thanks Crossword Clue
Prologistix Ein Number
Congressional hopeful Aisha Mills sees district as an economical model
Coldestuknow
Latest Posts
Article information

Author: Mr. See Jast

Last Updated:

Views: 5756

Rating: 4.4 / 5 (75 voted)

Reviews: 82% of readers found this page helpful

Author information

Name: Mr. See Jast

Birthday: 1999-07-30

Address: 8409 Megan Mountain, New Mathew, MT 44997-8193

Phone: +5023589614038

Job: Chief Executive

Hobby: Leather crafting, Flag Football, Candle making, Flying, Poi, Gunsmithing, Swimming

Introduction: My name is Mr. See Jast, I am a open, jolly, gorgeous, courageous, inexpensive, friendly, homely person who loves writing and wants to share my knowledge and understanding with you.