{"id":6271,"date":"2019-10-16T16:21:23","date_gmt":"2019-10-16T20:21:23","guid":{"rendered":"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/?p=6271"},"modified":"2025-04-04T10:02:53","modified_gmt":"2025-04-04T14:02:53","slug":"configuring-bearer-tokens","status":"publish","type":"post","link":"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/2019\/10\/configuring-bearer-tokens\/","title":{"rendered":"Configuring Bearer Tokens for Load Testing"},"content":{"rendered":"<p>A \u00a0method of authentication that has become more popular these days is\u00a0<a href=\"https:\/\/tools.ietf.org\/html\/rfc6750\">bearer tokens<\/a>, which require some additional configuration in Load Tester.<\/p>\n<p>You can first tell if a website uses bearer tokens because the site will throw <a href=\"https:\/\/en.wikipedia.org\/wiki\/HTTP_404\">404 errors<\/a> when attempting a playback. \u00a0Examing the headers will show a header entry called &#8220;Authorization&#8221; with the format shown below:<\/p>\n<p><a href=\"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-content\/uploads\/2019\/10\/Screen-Shot-2019-10-16-at-4.05.15-PM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6272\" src=\"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-content\/uploads\/2019\/10\/Screen-Shot-2019-10-16-at-4.05.15-PM.png\" alt=\"\" width=\"583\" height=\"76\" \/><\/a><\/p>\n<p>The value will appear one or more times. \u00a0Some sites just set the value once, and others will try and set it on different parts of a website.<\/p>\n<p>The first thing to do is find where the value appears using the Search Tab on the Response Content:<\/p>\n<p><a href=\"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-content\/uploads\/2019\/10\/Screen-Shot-2019-10-16-at-4.09.34-PM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-6273\" src=\"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-content\/uploads\/2019\/10\/Screen-Shot-2019-10-16-at-4.09.34-PM.png\" alt=\"\" width=\"600\" height=\"250\" \/><\/a><\/p>\n<p>The next step is to configure an extractor for the bearer token on Page 1, Transaction 6. \u00a0This example uses a regular expression, but you could use any of the three extractor types. \u00a0Note that this example is specific for this website; other sites may set the token values in different ways, so you&#8217;ll need to write an extractor that matches the website you&#8217;re testing.<\/p>\n<p><a href=\"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-content\/uploads\/2019\/10\/Screen-Shot-2019-10-16-at-4.12.49-PM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-6274\" src=\"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-content\/uploads\/2019\/10\/Screen-Shot-2019-10-16-at-4.12.49-PM.png\" alt=\"\" width=\"600\" height=\"423\" \/><\/a><\/p>\n<p>Now that the value will be put into the user variable &#8220;BearerToken&#8221;, the final step is to configure all of the headers to use this new value. \u00a0Go to the Headers Tab and select a view that displays the headers. \u00a0Selecting the top-level test case name in the Testcase Editor Tab will select all of the headers for every transaction. \u00a0Type in &#8220;Authorization&#8221; into the Filter input box on the bottom left, and all of the headers to be configured will be selected:<\/p>\n<p><a href=\"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-content\/uploads\/2019\/10\/Screen-Shot-2019-10-16-at-4.16.26-PM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-6275\" src=\"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-content\/uploads\/2019\/10\/Screen-Shot-2019-10-16-at-4.16.26-PM.png\" alt=\"\" width=\"600\" height=\"276\" \/><\/a><\/p>\n<p>Luckily with Load Tester, you don&#8217;t have to edit each one separately! \u00a0 Select all of the Authorization headers with values, right-click, and select Edit.<\/p>\n<p>Select a Datasource of Concatenation.<\/p>\n<p>Hit the green plus sign and select &#8220;Text Constant&#8221;. \u00a0 Enter &#8220;Bearer &#8220;. \u00a0 The space after the last &#8220;r&#8221; is very important.<\/p>\n<p><a href=\"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-content\/uploads\/2019\/10\/Screen-Shot-2019-10-16-at-4.18.16-PM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6276\" src=\"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-content\/uploads\/2019\/10\/Screen-Shot-2019-10-16-at-4.18.16-PM.png\" alt=\"\" width=\"512\" height=\"273\" \/><\/a><\/p>\n<p>Hit the green plus sign again and then select a data source of User Variable. \u00a0The name should be the one you chose in the extractor. \u00a0In this example, it is &#8220;BearerToken&#8221;.<\/p>\n<p><a href=\"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-content\/uploads\/2019\/10\/Screen-Shot-2019-10-16-at-4.19.21-PM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6277\" src=\"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-content\/uploads\/2019\/10\/Screen-Shot-2019-10-16-at-4.19.21-PM.png\" alt=\"\" width=\"511\" height=\"275\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>After you hit &#8220;OK&#8221;, all of the headers that require bearer tokens will be dynamically configured on playback. \u00a0Note that if your particular application changes the bearer token at different spots you&#8217;ll need to add more extractors, but that&#8217;s not too common.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A \u00a0method of authentication that has become more popular these days is\u00a0<a href=\"https:\/\/tools.ietf.org\/html\/rfc6750\">bearer tokens<\/a>, which require some additional configuration in Load Tester.<br \/>\nYou can first tell if a website uses bearer tokens because the site will throw <a href=\"https:\/\/en.wikipedia.org\/wiki\/HTTP_404\">404 errors<\/a> when attempting a playback. \u00a0Examing the headers will show a header entry called &#8220;Authorization&#8221; with the format shown below:<br \/>\n<a href=\"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-content\/uploads\/2019\/10\/Screen-Shot-2019-10-16-at-4.05.15-PM.png\"><\/a><br \/>\nThe value will appear one or more times. \u00a0Some sites just set the value once, and others will try and set it on different parts of a website.<br \/>\nThe first thing to do is find where the value appears using the Search Tab &hellip; <a href=\"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/2019\/10\/configuring-bearer-tokens\/\">Continue reading &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,42],"tags":[326,330,237,328],"class_list":["post-6271","post","type-post","status-publish","format-standard","hentry","category-load-testing","category-load-tester-software","tag-bearer","tag-bearer-token","tag-load-testing","tag-token"],"_links":{"self":[{"href":"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-json\/wp\/v2\/posts\/6271","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-json\/wp\/v2\/comments?post=6271"}],"version-history":[{"count":6,"href":"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-json\/wp\/v2\/posts\/6271\/revisions"}],"predecessor-version":[{"id":6283,"href":"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-json\/wp\/v2\/posts\/6271\/revisions\/6283"}],"wp:attachment":[{"href":"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-json\/wp\/v2\/media?parent=6271"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-json\/wp\/v2\/categories?post=6271"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-json\/wp\/v2\/tags?post=6271"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}