I have an application from which I want to make an authenticated call to a backoffice page. More specifically, I want to trigger an Import via Usync. However, to do that, I must pass some user credentials with my call.
HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://myumbracosite.local/umbraco/backoffice/usync/uSyncBackOffice/ImportAll");
req.UseDefaultCredentials = true;
req.Credentials = new NetworkCredential("[email protected]", "somepassword");
HttpWebResponse response = (HttpWebResponse)req.GetResponse();
response.Close();
In the above example, I pass the username and password of a backoffice via the Network Credentials class. Needless to say, it doesn’t work with my Umbracosite returning a 405, method not allowed exception.
What’s the best practice for making an authenticated call to a backoffice page? Do I need to fetch a cookie by first doing a post to the logon page or something of the like?
If anyone could provide some code samples, I’d be very grateful!
Thanks in advance!
This is a companion discussion topic for the original entry at https://our.umbraco.com/forum/81905-how-to-pass-umbraco-user-credentials-via-httpwebrequest