HomeGenie Forum

General Category => Troubleshooting and Support => Topic started by: rexz on October 24, 2015, 01:17:34 AM

Title: HTTP Basic Authorisation
Post by: rexz on October 24, 2015, 01:17:34 AM
I am trying to interact with VLC by using its built in web interface. VLC can present both json and xml and be controlled with commands but the problem I have is http authentication. There is no way to turn it off in VLC and I can't pass authentication via the url (i.e. http://<user>:<pass>@<ip address>:<port>. I would rather go down this route than built a tcp client to connect to it's dilapidated telnet interface.

Any help would be greatly appreciated.

Rexz
Title: Re: HTTP Basic Authorisation
Post by: rexz on October 24, 2015, 05:12:06 PM
Ok, after extensive searching I found that someone was able to replace the headers of the http request so that the credentials could be passed. Hope this helps anyone who might have had similar problems.

Code: [Select]
using (System.Net.WebClient client = new System.Net.WebClient())
    {
      credential = Convert.ToBase64String(Encoding.Default.GetBytes(":1234"));
      client.Headers[HttpRequestHeader.Authorization] = "Basic " + credential;
      webresult = client.DownloadString("http://127.0.0.1:9090/requests/status.json");
}
Title: Re: HTTP Basic Authorisation
Post by: dani on October 24, 2015, 07:58:19 PM
Have a sample of your work to show ? I am interresting

Cheers
Dani
Title: Re: HTTP Basic Authorisation
Post by: rexz on October 25, 2015, 01:05:13 PM
HI Dani,

Not just yet. My method is crude at best as I am just getting the basic functionality down. I'm not that great at c# so looking through lots of examples and learning as I go. My idea is that I will use VLC as my streaming music player as I am building a whole house audio system without the use of sonos boxes etc but actually built in ceiling speakers wired back to a central location. I can also run multiple instances of VLC using different sound cards to have different music playing in different rooms. I am also testing a widget I made that has an ON OFF switch and a drop down selection for the radio stations. I shall keep you updated on this post as I get it a bit more functional.

Cheers
Rexz