# Getting Auth Header Text From A Request

**URL:** <https://discourse.mitmproxy.org/t/getting-auth-header-text-from-a-request/368>\
**Category:** help\
**Created:** [February 20, 2017, 9:39am UTC](https://discourse.mitmproxy.org/t/getting-auth-header-text-from-a-request/368 "2017-02-20T09:39:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pashbee](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@Pashbee](https://discourse.mitmproxy.org/u/Pashbee)\
**Post date:** [February 20, 2017, 9:39am UTC](https://discourse.mitmproxy.org/t/getting-auth-header-text-from-a-request/368/1 "2017-02-20T09:39:39Z")

</div>

Hi,

So I am running a simple piece of code to extract Authorization header from a request. Like so:-

```
from mitmproxy import ctx

class ApiRequest(object):

    def apirequest(self, flow):
        ctx.log.info("### AUTH REQUESTED ### --> %s" %
                     flow.request.headers['Proxy-Authorization'])

def start():
    return ApiRequest()

```

I am running this like so:-

mitmdump -s [test.py](http://test.py) -p 8020 --nonanonymous

Point my local MAC to use this proxy and I try a curl like this:-

curl -x [https://user:user@127.0.0.1:8020](https://user:user@127.0.0.1:8020) -vvv url

I always get back a 401 no matter what and a KeyError on the request.

I want to retreive the Proxy-Authorization b64 encoded string so that I can pass auth to my own backend.

How do I achieve this?

Thanks,

---

<div class="post-metadata">

**Author:** ![mhils](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mitmproxy.org/mhils/32/7_2.png) [@mhils](https://discourse.mitmproxy.org/u/mhils)\
**Post date:** [February 21, 2017, 1:56pm UTC](https://discourse.mitmproxy.org/t/getting-auth-header-text-from-a-request/368/2 "2017-02-21T13:56:22Z")

</div>

Hi,

We fixed some issues regarding that lately, this will be fixed with the next release:  
[https://github.com/mitmproxy/mitmproxy/issues/1734](https://github.com/mitmproxy/mitmproxy/issues/1734)  
[https://github.com/mitmproxy/mitmproxy/issues/2019](https://github.com/mitmproxy/mitmproxy/issues/2019)

Best,  
Max

---

<div class="post-metadata">

**Author:** ![Pashbee](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@Pashbee](https://discourse.mitmproxy.org/u/Pashbee)\
**Post date:** [February 21, 2017, 3:18pm UTC](https://discourse.mitmproxy.org/t/getting-auth-header-text-from-a-request/368/3 "2017-02-21T15:18:20Z")

</div>

Ok, thanks Max. Ill keep an eye out for this fix.
