# How to access proxy user from inline script

**URL:** <https://discourse.mitmproxy.org/t/how-to-access-proxy-user-from-inline-script/107>\
**Category:** Uncategorized\
**Created:** [July 28, 2016, 6:14pm UTC](https://discourse.mitmproxy.org/t/how-to-access-proxy-user-from-inline-script/107 "2016-07-28T18:14:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![AnalogJ](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mitmproxy.org/analogj/32/42_2.png) [@AnalogJ](https://discourse.mitmproxy.org/u/AnalogJ)\
**Post date:** [July 28, 2016, 6:14pm UTC](https://discourse.mitmproxy.org/t/how-to-access-proxy-user-from-inline-script/107/1 "2016-07-28T18:14:11Z")

</div>

Hi,  
I’m running mitmdump with the `nonanonymous` flag enabled. I’m trying to get the value of the proxy username which is stored in the `self.username` variable that’s defined in the `BasicProxyAuth` class: [https://github.com/mitmproxy/mitmproxy/blob/1dd078beb23aa0b483f945eed39c0136984f81a6/netlib/http/authentication.py#L76](https://github.com/mitmproxy/mitmproxy/blob/1dd078beb23aa0b483f945eed39c0136984f81a6/netlib/http/authentication.py#L76)

I’ve tried tracing the code, and looking at the events available to inline scripts: [http://docs.mitmproxy.org/en/v0.17/scripting/inlinescripts.html#events](http://docs.mitmproxy.org/en/v0.17/scripting/inlinescripts.html#events)

I’ve tried looking at the `clientconnect` and `request` events, and I just haven’t been able to find the data I need.

Any help would be appreciated.

---

<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:** [July 30, 2016, 3:21am UTC](https://discourse.mitmproxy.org/t/how-to-access-proxy-user-from-inline-script/107/2 "2016-07-30T03:21:32Z")

</div>

Hi @AnalogJ,

looks like there is indeed no good way to do this at the moment - we clean the headers [here](https://github.com/mitmproxy/mitmproxy/blob/63f64cd66086f302f53456f29f60b1e28c8ee178/mitmproxy/protocol/http.py#L398) before passing the request to the inline script. I’d be happy to accept a PR that keeps the authentication at this place but moves the cleaning part below the `process_request_hook` call! 🙂
