Hi All,
I am trying to do authentication in my Xamarin.Forms mobile app with on-premise SharePoint server.
I am following Microsoft SharePoint documentation:
Sample code is:
string SharePointUrl = "Target SharePoint site";
private void AuthenticateToSharePoint(object sender, RoutedEventArgs e)
{
ODataAuthenticator odataAt = new ODataAuthenticator("", "");
odataAt.CookieCachingEnabled = true;
odataAt.AuthenticationCompleted += new EventHandler(odataAt_AuthenticationCompleted);
odataAt.Authenticate(new Uri(SharePointUrl, UriKind.Absolute));
}
void odataAt_AuthenticationCompleted(object sender, AuthenticationCompletedEventArgs e)
{
HttpWebRequest endpointRequest = (HttpWebRequest)HttpWebRequest.Create(SharePointUrl.ToString() + "/_api/web/lists");
endpointRequest.Method = "GET";
endpointRequest.Accept = "application/json;odata=verbose";
endpointRequest.CookieContainer = (sender as ODataAuthenticator).CookieContainer;
endpointRequest.BeginGetResponse(new AsyncCallback((IAsyncResult res) =>
{
HttpWebRequest webReq = res.AsyncState as HttpWebRequest;
WebResponse response = webReq.EndGetResponse(res);
HttpWebResponse httpResponse = response as HttpWebResponse;
HttpStatusCode code = httpResponse.StatusCode;
this.Dispatcher.BeginInvoke(() =>
{
MessageBox.Show(code.ToString());
});
}), endpointRequest);
}
I am unable to find reference to "ODataAuthenticator" class, and also "RoutedEventArgs", "AuthenticationCompletedEventArgs" in Xamarin.Forms.
Also, this code seems incomplete. How to invoke the event is not mentioned.
If someone has done similar to that then please provide help.
Thanks for the help, Neeraj