# Using bearer auth token

**URL:** <https://discuss.hangfire.io/t/using-bearer-auth-token/2166>\
**Category:** question\
**Created:** [July 1, 2016, 10:30pm UTC](https://discuss.hangfire.io/t/using-bearer-auth-token/2166 "2016-07-01T22:30:29Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![dynamiclynk](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.hangfire.io/dynamiclynk/32/920_2.png) [@dynamiclynk](https://discuss.hangfire.io/u/dynamiclynk)\
**Post date:** [April 26, 2017, 4:27pm UTC](https://discuss.hangfire.io/t/using-bearer-auth-token/2166/4 "2017-04-26T16:27:17Z")

</div>

I went this route in my Hangfire Authorize Attribute, since I passed my Bearer token via querystring to the entry /dashboard URL then I have middleware to add the bearer token to the Authorization header.

So the first entry into the Dashboard passes auth but the other dashboard resources fail auth because of no Authorization header being transient from the original request, but I noticed the _referer header_ specifies the original URL with auth token query param…so I was able to get the access\_token from the header and validate it for any dashboard resource call…now to work on the refreshing of the token.

_CustomJwtSecurityTokenHandler_ is my implementation but you can just using the JwtSecurityTokenHandler

 ![](https://europe1.discourse-cdn.com/flex017/uploads/hangfire/original/1X/302968c7e1b7a032f76b13857b92c100fb8fd2ee.png)

Update: Other links are broken (auth failing) because the referer changes when it comes from another page in Hangfire, so I’ll just store it as a cookie and read it from there that’s the plan. Using the cookie works perfect.

 ![](https://europe1.discourse-cdn.com/flex017/uploads/hangfire/original/1X/a486397a491fec44aafc1f1734b354165ee0e96c.png)

Also using jquery, after successful auth I loaded the dashboard via iframe so no point for back to site, and the jquery client can keep the token refresh via a timer after the JWT expires 🙂

 ![](https://europe1.discourse-cdn.com/flex017/uploads/hangfire/original/1X/c71526e473b1f85bc353b364fea2da9196e2a9a1.png)

 ![](https://europe1.discourse-cdn.com/flex017/uploads/hangfire/original/1X/ea1df813dd35a7f071bd6d77f18fe7a2b80cc05f.png)

Good luck!

---

_[View the full topic](https://discuss.hangfire.io/t/using-bearer-auth-token/2166)._
