I'm trying to access an RSS feed that requires Basic HTTP Authentication, but I can't seem to get it to work. I've also created an equivalent example in Python that works correctly, and returns my expected results.
My BrightScript code:
'BrightScript example to retrieve a protected RSS feed with Basic HTTP Authentication.
'This does NOT work for me. http.GetToString() doesn't return anything.
http = CreateObject("roUrlTransfer")
http.SetUrl("http://www.my-restricted-site.com/")
ba = CreateObject("roByteArray")
ba.FromAsciiString("username:password")
http.AddHeader("Authorization", "Basic " + ba.ToBase64String())
print "Results: "; http.GetToString()
This equivalent example in Python works as expected:
#Python example to retrieve a protected RSS feed with Basic HTTP Authentication.
#This DOES work for me.
import urllib2
import base64
myurl = 'http://www.my-restricted-site.com/'
username = 'username'
password = 'password'
req = urllib2.Request(myurl)
base64string = base64.encodestring( '%s:%s' % (username, password) )[:-1]
authheader = "Basic %s" % base64string
req.add_header("Authorization", authheader)
try:
handle = urllib2.urlopen(req)
print handle.read()
except IOError, e:
print "Wrong user/pass"
The Roku documentation for ifUrlTransfer contains the following passage, which has me a little worried:
"Boolean SetUserAndPassword(String user, String password)
- Enables HTTP authentication using the specified user name and password. Note that HTTP basic authentication is deliberately disabled due to it being inherently insecure. HTTP digest authentication is supported.
Any help would be greatly appreciated.
My Roku Channels:
Viddler - viddler.com
Tested Fan - tested.com | Jamie & Adam
This is my next - theverge.com
1080p Showcase - RIP
Whiskey Media - RIP
======================
http://www.binarymoustache.com