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: 
tboneus
Visitor

Possible pointers for authorization of local device

Probably way off base here but I am trying to communicate with a WDTV Live so that the actions on the Roku can control the other device. I have the code working on the WDTV from a web browser so I just need to send the same instruction from the roku

The code I use is:
http://192.168.2.2/tmp/rokuRemote.php?button=&button=[then what ever action I have defined in the php script on the wdtv]

For example sending : http://192.168.2.2/tmp/rokuRemote.php?button=&button=r emulates a right click on the remote control.

The problem I have is authorizing the communication. Using http://192.168.2.2 on a web browser produces a request for a user name and password (in this case they are both wdlxtv). I have tried to send this from a Script on the Roku using
Function AuthorizeCommsForWdtvControl(url As String)

http = CreateObject("roUrlTransfer")
http.SetUrl(url)

ba = CreateObject("roByteArray")
ba.FromAsciiString("wdlxtv:wdlxtv")
http.AddHeader("Authorization", "Basic " + ba.ToBase64String())

End Function

but I get nothing back from the Print http.GetToString() so clearly I am looking at this problem incorrectly as I expected some form of a request then to send the authorization details (I think this is using basic authorization). Another thread viewtopic.php?f=34&t=34721 mentioned a similar issue but that was using SSL and a https url which I do not believe is the case in this circumstance.

Is there a way to accomplish this in a script?
0 Kudos
5 REPLIES 5
jbrave
Channel Surfer

Re: Possible pointers for authorization of local device

isn't the standard way to send username and password via url like:

http://username:password@192.168.2.2

so you could go:


http.SetURL("http://username:password@192.168.2.2/tmp/rokuRemote.php?button=&button=r")
Screenshades: The first Screensaver for Roku2!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
0 Kudos
RokuKevin
Visitor

Re: Possible pointers for authorization of local device

You need to figure out what kind of authorization WDTV is using... You've described a method for Basic authorization, but it may be something different. I'd take a wireshark trace of your browser interacting with WDTV and then emulate the same traffic using the Roku as the client.

If you are using SSL, try to turn that requirement off before taking your wireshark trace so that you can analyze the requests...

--Kevin
0 Kudos
tboneus
Visitor

Re: Possible pointers for authorization of local device

Thank you for your responses. I used Wireshark and indeed the method being employed is not basic authentication but instead Digest access authentication. I will take another look during the week when I have more time to identify what needs to be sent.
0 Kudos
YungBlood
Streaming Star

Re: Possible pointers for authorization of local device

"ComponentReference.pdf" wrote:

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.

Digest auth is built in.
YungBlood

Bringing more fun to Roku!
0 Kudos
tboneus
Visitor

Re: Possible pointers for authorization of local device

Thanks guys, got it working. As YungBlood pointed out, digest authorization is built in so just needed to pass the username and password.

In case anyone might find it useful in the future the working code was:

conn = CreateObject("roAssociativeArray")
conn.UrlPrefix = "http://192.168.2.2/tmp/rokuRemote.php?button=&button="
conn.UrlCategoryFeed = conn.UrlPrefix + dir

http = CreateObject("roUrlTransfer")
http.SetUrl(conn.UrlCategoryFeed)
http.SetUserAndPassword("wdlxtv","wdlxtv")
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.