Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
vlaine
Channel Surfer

Re: Need help with Roku2 HLS : error 403

As suggested,I extracted the cookies values.
I tried 2 different things:

' First try: cookies string. Contains only the cookies values.
hdntl=exp=1333591523~acl=%2f*~data=hdntl~hmac=49ee61ec6c7c9fb11dfe428a1a4ed156a0
7530c283c5168a31eb76842279d2df;_alid_=j36jjnPsegnLAxaFnJaTkQ==

' Second try: cookies string after replacing the ~ by a ;

hdntl=exp=1333591523;acl=%2f*;data=hdntl;hmac=49ee61ec6c7c9fb11dfe428a1a4ed156a0
7530c283c5168a31eb76842279d2df;_alid_=j36jjnPsegnLAxaFnJaTkQ==

When I add a cookie to the video, I add it like this:
video.AddHeader("Cookie", cookies)

It was a bright idea, but It didn't work.
The cookie is required for the master m3u8 file and I can get it with success.
Why can I get it with success, but fail with the nested m3u8 files ?
0 Kudos
belltown
Roku Guru

Re: Need help with Roku2 HLS : error 403

Another thing you could try is url-encoding the value part of the cookies' name=value pairs.

So, if you have cookieName and cookieValue, use:

cookieEncoded = cookieName + "=" + CreateObject ("roUrlTransfer").Escape (cookieValue)

The reason is that certain characters, e.g. "=" are not allowed as the cookie value as they have other meanings (separating the name from the value), so they must be encoded (e.g. "=" would be encoded as "%3D"). The Escape method does this encoding for you (or you may need to use UrlEncode instead; I'm not really clear on the difference).

Your cookies contain "=" characters as part of the value (e.g. the "==" sequence at the end, a sequence typically generated when encoding binary data using a Base64 encoding).

Its a pity that data can only be accessed from Canada, otherwise it would be easier for others here to help debug the problem for you.
0 Kudos
vlaine
Channel Surfer

Re: Need help with Roku2 HLS : error 403

Grrr
I applied your suggestion with no success.
Encoding the cookie doesn't resolve the error 403.
I really don't understand.
0 Kudos
RokuMarkn
Visitor

Re: Need help with Roku2 HLS : error 403

I can't really help other than to say, if I were in your position I would ditch the Roku for now and try to do the appropriate fetches with a tool like curl. If you can make curl fetch the playlists successfully, you'll know exactly what the server requires, and you'll be in a much better position to then write the code to make the Roku to do the same.

--Mark
0 Kudos
bosborne
Visitor

Re: Need help with Roku2 HLS : error 403

I am running into this same issue.

I can play back the token-protected stream just fine. However, the Roku gets 403s for the variant playlists. This is likely because it is not properly passing the Cookie headers back and forth.

Can someone from the Roku team confirm whether or not Roku will accept cookies that are set?

The way this works is that the Roku generates a token and appends it to the URL for the master manifest. Once that request is received by the CDN and the token is authorized, the CDN will then set a new token as a cookie header in the response. Subsequent requests for the variant playlists and TS files need to then have that cookie header sent along as well, which the CDN validates.
0 Kudos
TheEndless
Channel Surfer

Re: Need help with Roku2 HLS : error 403

"bosborne" wrote:
I am running into this same issue.

I can play back the token-protected stream just fine. However, the Roku gets 403s for the variant playlists. This is likely because it is not properly passing the Cookie headers back and forth.

Can someone from the Roku team confirm whether or not Roku will accept cookies that are set?

The way this works is that the Roku generates a token and appends it to the URL for the master manifest. Once that request is received by the CDN and the token is authorized, the CDN will then set a new token as a cookie header in the response. Subsequent requests for the variant playlists and TS files need to then have that cookie header sent along as well, which the CDN validates.

The Roku doesn't support cookies natively. You'd need to read the headers and manage the cookies programmatically.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
bosborne
Visitor

Re: Need help with Roku2 HLS : error 403

I don't actually make the request for the variant playlists or TS chunks, the video screen does, so is that possible?
0 Kudos
TheEndless
Channel Surfer

Re: Need help with Roku2 HLS : error 403

"bosborne" wrote:
I don't actually make the request for the variant playlists or TS chunks, the video screen does, so is that possible?

Most likely, you'd need to make a roUrlTransfer request for the playlist first just to get the cookies, read the cookies from the headers of that request, then call AddHeader() on the roVideoScreen to add the cookie header before starting playback.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
bosborne
Visitor

Re: Need help with Roku2 HLS : error 403

That's unlikely to work, as the cookie headers that the CDN creates will likely be different the second time that the request is made (by the video player) for the manifest. I can try this though.
0 Kudos
bosborne
Visitor

Re: Need help with Roku2 HLS : error 403

I realize it's been quite a while, but I wanted to follow up on this.

On my basic roVideoScreen object, I enabled cookies by setting screen.EnableCookies(). To my understanding, every HTTP request made by the roVideoScreen will then be able to receive any cookies that were set by the server and then include then back in any future requests.

Is that not the case? Otherwise, how can I do this? I have to read the cookies and manually set them each time? If so, what's the point of EnableCookies?

I need the cookies that are set from the initial request of the m3u8 to persist for the sub-playlists, .key files, and .ts segments.
0 Kudos