# Extracting authorization token from response headers using headerRegex.

**URL:** https://community.gatling.io/t/extracting-authorization-token-from-response-headers-using-headerregex/5651
**Category:** Gatling (Open-Source)
**Created:** [June 2, 2020, 5:25pm UTC](https://community.gatling.io/t/extracting-authorization-token-from-response-headers-using-headerregex/5651 "2020-06-02T17:25:10Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![srinivas\_magapu](https://avatars.discourse-cdn.com/v4/letter/s/f475e1/32.png) [@srinivas\_magapu](https://community.gatling.io/u/srinivas_magapu)
#### Post date: [June 2, 2020, 5:25pm UTC](https://community.gatling.io/t/extracting-authorization-token-from-response-headers-using-headerregex/5651/1 "2020-06-02T17:25:10Z")

</div>

Hi Team,

Could you please help me in handling authorization token from response headers using headerRegex.

Response Headers  
Set-Cookie: \__**\_loggedin=false; [Domain=xxxx.com](http://Domain=xxxx.com); Path=/  
Set-Cookie: PNOODLE=""; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/  
Set-Cookie: PNOODLE=f520b2e1-6fbe-45e5-a3f8- ** __; Domain=__ **.com; Path=/  
Set-Cookie: oa2=%3Bdx1Rx3Tjip9bozPu5UiZUUz0vWMdLqYD3YJSWa%2BMAP3BMqjY9NbkMUR46F%2BC1yhbsO2VSiaEB%2BRHE2ItowKvrUKnGfa7ZVhYr1PSKOCuvc5kWi54CHasePpEYG%2xVkt6oLIVu5AEVLpIEgN%2Fe%2FqMUvjQnJGH%2B7P0uGi4WRiaL%2BjE8dWdVWerCY5BtSQw0KGDe2TSHOfnO2UjTXos4U3inDEIuYU7Y7HCHlhrwEcr9vpR4%3D; Domain=**_\*.com; Path=/; Secure;

FYI…  
I tried below options. Could able to get value from getCookieValue(), but not from

```auto
headerRegex

```

headerRegex((Set-Cookie,oa2=(.\*?))).find.exists, found nothing

```auto
 .check(headerRegex("Set-Cookie", "oa2=(.*?)").saveAs("oauthidno")))

.exec(
  getCookieValue(
    CookieKey("oa2")
      .withSecure(true)
      .saveAs("OAUTHID")
      .withDomain("XXXX.com")
  )

Thanks & Regards,
Srinivas M

```

Click here to Reply
