INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Webclient interace authentication  (Read 2881 times)

TomNKY

  • Recent member
  • *
  • Posts: 25
Webclient interace authentication
« on: July 06, 2013, 02:44:47 pm »

Has anyone an idea about getting password & username into the webservice without relying on the popup form? Within a WP8 app, it doesn't want to allow passing these via the URL. Any ideas? 

string authenticate = string.Format("http://{0}:{1}@{2}:{3}/MCWS/v1/Authenticate",
                    App.TheSession.JRiverServer.Username,
                    App.TheSession.JRiverServer.Password,
                    App.TheSession.JRiverServer.UseIP,
                    App.TheSession.JRiverServer.Port );

passed down ultimately into something like

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
                request.Method = HttpMethod.Get;
                HttpWebResponse response = (HttpWebResponse)await request.GetResponseAsync();

isn't accepting the parameters or formate. I notice that pasted into IE it won't work, apsted into Firefox,Opera or Chrome it does....  MS doesn't consider this method to be secure. 

Thoughts?
Logged

fridden

  • Recent member
  • *
  • Posts: 31
Re: Webclient interace authentication
« Reply #1 on: July 07, 2013, 01:41:49 am »

Hi,
Have you tried using the Credential property of the HttpWebRequest object with a NetworkCredential object?
Googling around I found this at StackoverFlow

Code: [Select]
NetworkCredential nc = new NetworkCredential(GetSetting("username"), GetSetting("password"));
CredentialCache cache = new CredentialCache();

cache.Add(requestUri, "Basic", nc);

HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(requestUri);

The Stackoverflow post is found at http://stackoverflow.com/questions/1683398/passing-networkcredential-to-httpwebrequest-in-c-sharp-from-asp-net-page

Hope this helps!
/Fridden
Logged

TomNKY

  • Recent member
  • *
  • Posts: 25
Re: Webclient interace authentication
« Reply #2 on: July 07, 2013, 11:15:26 am »

Hi,
Have you tried using the Credential property of the HttpWebRequest object with a NetworkCredential object?
Googling around I found this at StackoverFlow

Code: [Select]
NetworkCredential nc = new NetworkCredential(GetSetting("username"), GetSetting("password"));
CredentialCache cache = new CredentialCache();

cache.Add(requestUri, "Basic", nc);

HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(requestUri);

The Stackoverflow post is found at http://stackoverflow.com/questions/1683398/passing-networkcredential-to-httpwebrequest-in-c-sharp-from-asp-net-page

Hope this helps!
/Fridden


Thanks for the idea ... been checking this out this morning and it appears I've got it working using the network credentials !! Passing Tokens back in on the other commands in my program and so far all seem to work. Have to double check every one of them but think this fits the bill.

Thanks A Bunch !
Logged
Pages: [1]   Go Up