# Fastly HMAC authentication for playback not working

**URL:** <https://community.wowza.com/t/fastly-hmac-authentication-for-playback-not-working/54717>\
**Category:** Wowza Developer Dojo\
**Created:** [February 27, 2020, 1:36pm UTC](https://community.wowza.com/t/fastly-hmac-authentication-for-playback-not-working/54717 "2020-02-27T13:36:42Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thomas\_B](https://avatars.discourse-cdn.com/v4/letter/t/6a8cbe/32.png) [@Thomas\_B](https://community.wowza.com/u/Thomas_B)\
**Post date:** [February 27, 2020, 1:36pm UTC](https://community.wowza.com/t/fastly-hmac-authentication-for-playback-not-working/54717/1 "2020-02-27T13:36:42Z")

</div>

Hi,

At the moment I am trying to configure token authentication for playback from the Fastly CDN. I used the [python example](https://github.com/WowzaMediaSystems/wsc-fastly-token-auth-examples/blob/c96fa93b1a5f91ae64dff77a0de482bbeb7aee43/python/gen_token.py) supplied by Wowza. The stream id is added, the expiration is added, but we keep on getting 403 Forbidden responses.

Steps to reproduce:

- Create a Fastly CDN Streaming target for a livestream

- Enable authentication and get the shared secret

- Start the livestream

- Start livestreaming from OBS

- Create a HMAC key using the python example

- Attempt to connect to the Fastly streaming target url with the HMAC attached to the url as specified [here](https://www.wowza.com/docs/protect-a-wowza-cdn-on-fastly-stream-target-with-token-authentication-using-the-wowza-streaming-cloud-rest-api) (bottom of the page).

- Get a 403 Forbidden response

Are there specific details about the HMAC token that might solve our issue?

Thanks in advance!

-Thomas

---

<div class="post-metadata">

**Author:** ![Thomas\_B](https://avatars.discourse-cdn.com/v4/letter/t/6a8cbe/32.png) [@Thomas\_B](https://community.wowza.com/u/Thomas_B)\
**Post date:** [February 27, 2020, 4:33pm UTC](https://community.wowza.com/t/fastly-hmac-authentication-for-playback-not-working/54717/2 "2020-02-27T16:33:42Z")

</div>

I see my hyperlinks didn’t work in the text.

Python example: [https://github.com/WowzaMediaSystems/wsc-fastly-token-auth-examples/blob/master/python/gen\_token.py](https://github.com/WowzaMediaSystems/wsc-fastly-token-auth-examples/blob/master/python/gen_token.py)

Fastly HMAC documentation example (bottom of the page): [https://www.wowza.com/docs/protect-a-wowza-cdn-on-fastly-stream-target-with-token-authentication-using-the-wowza-streaming-cloud-rest-api](https://www.wowza.com/docs/protect-a-wowza-cdn-on-fastly-stream-target-with-token-authentication-using-the-wowza-streaming-cloud-rest-api)

---

<div class="post-metadata">

**Author:** ![Mac\_Hill](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/mac_hill/32/434_2.png) [@Mac\_Hill](https://community.wowza.com/u/Mac_Hill)\
**Post date:** [February 27, 2020, 3:30pm UTC](https://community.wowza.com/t/fastly-hmac-authentication-for-playback-not-working/54717/3 "2020-02-27T15:30:47Z")

</div>

Hello Thomas,

I would suggest [opening a support ticket](https://www.wowza.com/portal/help/cloud) so we can review your specific details in your script and the account. Aside from what is already in the resources you have referenced, it would need a review.

Regards,  
Mac

---

<div class="post-metadata">

**Author:** ![Amara\_Graham](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/amara_graham/32/381_2.png) [@Amara\_Graham](https://community.wowza.com/u/Amara_Graham)\
**Post date:** [February 27, 2020, 4:33pm UTC](https://community.wowza.com/t/fastly-hmac-authentication-for-playback-not-working/54717/4 "2020-02-27T16:33:34Z")

</div>

Full disclosure, I have not tested the Fastly HMAC auth, but I have tested others in the Wowza ecosystem.

Double checking here, you mean the python example from over here - [https://github.com/WowzaMediaSystems/wsc-fastly-token-auth-examples](https://github.com/WowzaMediaSystems/wsc-fastly-token-auth-examples) ?

Have you tried this in curl? Does it work?

---

<div class="post-metadata">

**Author:** ![Anton\_Globa1](https://avatars.discourse-cdn.com/v4/letter/a/cc9497/32.png) [@Anton\_Globa1](https://community.wowza.com/u/Anton_Globa1)\
**Post date:** [March 4, 2020, 3:10pm UTC](https://community.wowza.com/t/fastly-hmac-authentication-for-playback-not-working/54717/5 "2020-03-04T15:10:11Z")

</div>

Hi,

I also have this problem.

I also tried to take a signature from wowza cloud ui. Advanced -\> Stream Targets -\> - \> Security Tab. “Generate Query Parameters” button. The result is same. I get 403 error.

I found mistake in python code. Line 103 contain that code:

```auto
return'hdnts=%shmac=%s'% (new_token, token_hmac). 

```

I think it need “~” symbol before “hmac=”.

Adding this character does not solve problem.

---

<div class="post-metadata">

**Author:** ![Rose\_Power-Wowza\_Com](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/rose_power-wowza_com/32/431_2.png) [@Rose\_Power-Wowza\_Com](https://community.wowza.com/u/Rose_Power-Wowza_Com)\
**Post date:** [March 4, 2020, 3:39pm UTC](https://community.wowza.com/t/fastly-hmac-authentication-for-playback-not-working/54717/6 "2020-03-04T15:39:30Z")

</div>

Thanks for letting us know @Anton Globa To let you know we are working on this and will post a resolution soon.

---

<div class="post-metadata">

**Author:** ![Thomas\_B](https://avatars.discourse-cdn.com/v4/letter/t/6a8cbe/32.png) [@Thomas\_B](https://community.wowza.com/u/Thomas_B)\
**Post date:** [March 5, 2020, 11:03am UTC](https://community.wowza.com/t/fastly-hmac-authentication-for-playback-not-working/54717/7 "2020-03-05T11:03:45Z")

</div>

I tried it with the ~ symbol as well, but that did not solve the issue unfortunately.

---

<div class="post-metadata">

**Author:** ![Thomas\_B](https://avatars.discourse-cdn.com/v4/letter/t/6a8cbe/32.png) [@Thomas\_B](https://community.wowza.com/u/Thomas_B)\
**Post date:** [March 5, 2020, 11:05am UTC](https://community.wowza.com/t/fastly-hmac-authentication-for-playback-not-working/54717/8 "2020-03-05T11:05:59Z")

</div>

Curl does not seem to make a difference.

I still get the 403 forbidden response.

---

<div class="post-metadata">

**Author:** ![Amara\_Graham](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/amara_graham/32/381_2.png) [@Amara\_Graham](https://community.wowza.com/u/Amara_Graham)\
**Post date:** [March 5, 2020, 3:58pm UTC](https://community.wowza.com/t/fastly-hmac-authentication-for-playback-not-working/54717/9 "2020-03-05T15:58:12Z")

</div>

So it sounds like we have two issues going on here, one is with the query parameter generator and the other is with the example code. I’ll see if I can help dig into this today. I know the team was focused on getting a release out the door. Thank you for your patience!

---

<div class="post-metadata">

**Author:** ![Amara\_Graham](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/amara_graham/32/381_2.png) [@Amara\_Graham](https://community.wowza.com/u/Amara_Graham)\
**Post date:** [March 5, 2020, 8:27pm UTC](https://community.wowza.com/t/fastly-hmac-authentication-for-playback-not-working/54717/10 "2020-03-05T20:27:46Z")

</div>

Can you help me understand what you are setting your token lifetime (in seconds) and start time (UTC seconds, or now) to? You might be getting a 403 because of that.

---

<div class="post-metadata">

**Author:** ![Amara\_Graham](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/amara_graham/32/381_2.png) [@Amara\_Graham](https://community.wowza.com/u/Amara_Graham)\
**Post date:** [March 5, 2020, 10:48pm UTC](https://community.wowza.com/t/fastly-hmac-authentication-for-playback-not-working/54717/11 "2020-03-05T22:48:22Z")

</div>

Within the 10 minute window yours produces a 403?

---

<div class="post-metadata">

**Author:** ![Amara\_Graham](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/amara_graham/32/381_2.png) [@Amara\_Graham](https://community.wowza.com/u/Amara_Graham)\
**Post date:** [March 9, 2020, 3:58pm UTC](https://community.wowza.com/t/fastly-hmac-authentication-for-playback-not-working/54717/12 "2020-03-09T15:58:14Z")

</div>

As an FYI, this was moved to a support ticket by @Thomas B. Please respond to your support ticket so we can get a quick recap out here for folks in the future. Thanks!

---

<div class="post-metadata">

**Author:** ![Amara\_Graham](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/amara_graham/32/381_2.png) [@Amara\_Graham](https://community.wowza.com/u/Amara_Graham)\
**Post date:** [March 9, 2020, 3:59pm UTC](https://community.wowza.com/t/fastly-hmac-authentication-for-playback-not-working/54717/13 "2020-03-09T15:59:46Z")

</div>

@Anton Globa if you are still experiencing an issue with the Generate Query Parameters, please open a support ticket. I’m not able to reproduce this.

Also, please make sure you are using the Generate Query Parameters button on the stream you are intending to use the query parameters on. These values are not interchangable across streams.

---

<div class="post-metadata">

**Author:** ![Anton\_Globa1](https://avatars.discourse-cdn.com/v4/letter/a/cc9497/32.png) [@Anton\_Globa1](https://community.wowza.com/u/Anton_Globa1)\
**Post date:** [March 10, 2020, 4:37am UTC](https://community.wowza.com/t/fastly-hmac-authentication-for-playback-not-working/54717/14 "2020-03-10T04:37:35Z")

</div>

In python generator i use 30000 for lifetime param.

In Wowza Cloud Web UI “Generate Query Param”: “Append the query parameters to all playback URLs for testing. Parameters expire 10 minutes after they’re created.” 10 minutes

---

<div class="post-metadata">

**Author:** ![Thomas\_B](https://avatars.discourse-cdn.com/v4/letter/t/6a8cbe/32.png) [@Thomas\_B](https://community.wowza.com/u/Thomas_B)\
**Post date:** [March 10, 2020, 1:15pm UTC](https://community.wowza.com/t/fastly-hmac-authentication-for-playback-not-working/54717/15 "2020-03-10T13:15:18Z")

</div>

Hi all,

I figured out (together with the support ticket ofc) what the problem was. When generating the tokens using the command line python implementation, I kept on using the wowza API stream id where I should have used the fastly stream id (I guess? still vague). Anyways, this bit solved it:

-u, --stream\_id STREAMID(required) The stream ID from the Wowza Streaming Cloud playback URL, which is the playback\_url of the Wowza CDN on Fastly stream target. Using this example, https://[subdomain].wowza.com/1/[stream\_id]/[stream\_name]/hls/live/playlist.m3u8, the value would be [stream\_id].

I was using the id from the [https://api.cloud.wowza.com/api/v1.4/live\_streams/[LIVESTREAM\_ID]](https://api.cloud.wowza.com/api/v1.4/live_streams/%5BLIVESTREAM_ID%5D) link that you use to reach the Wowza API.

Hopefully this will help others and keep people from being stuck on the “not-reading-the-manual-clear-enough” mistake that I made. When I saw the python instructions I blindly assumed the stream\_id would have to be the one being used in the wowza API.

Cheers!

-Thomas

---

<div class="post-metadata">

**Author:** ![Amara\_Graham](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/amara_graham/32/381_2.png) [@Amara\_Graham](https://community.wowza.com/u/Amara_Graham)\
**Post date:** [March 10, 2020, 1:21pm UTC](https://community.wowza.com/t/fastly-hmac-authentication-for-playback-not-working/54717/16 "2020-03-10T13:21:34Z")

</div>

Thanks for circling back and following up here Thomas! I’ll work with the documentation team to see if we can make that a little easier (or more obvious) to understand.

---

<div class="post-metadata">

**Author:** ![Anton\_Globa1](https://avatars.discourse-cdn.com/v4/letter/a/cc9497/32.png) [@Anton\_Globa1](https://community.wowza.com/u/Anton_Globa1)\
**Post date:** [March 10, 2020, 3:42pm UTC](https://community.wowza.com/t/fastly-hmac-authentication-for-playback-not-working/54717/17 "2020-03-10T15:42:42Z")

</div>

I also solved my problem, but it turned out to be different.

I checked the page with the player in another browser (Firefox). The page opened without problems.

The player did not work only in the chrome browser.

As I found out later due to the fact that the browser did not send cookies to the second request for chunklist.m3u8.

To solve the problem with the Chrome browser, I turned on authorization token only for the playlist

---

<div class="post-metadata">

**Author:** ![Amara\_Graham](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/amara_graham/32/381_2.png) [@Amara\_Graham](https://community.wowza.com/u/Amara_Graham)\
**Post date:** [March 10, 2020, 3:45pm UTC](https://community.wowza.com/t/fastly-hmac-authentication-for-playback-not-working/54717/18 "2020-03-10T15:45:08Z")

</div>

Glad to hear it! Thanks for coming back to update your post.
