I have a share-point addin need to create the xamarin application. So need access to all the share-point online rest API.
As per the Microsoft document we need to register app on Azure AD.
I don't want to register the app in Azure AD, I already have share point adding
I have Tried the MSAL and ADAL Library provide by Microsoft for accessing. To used them we need to register app on Azure AD.
here is the code which I have written to access direct share-point rest API.
private const string GetCalendarEventsUrl = "{tenant}/_api/web/lists/getbytitle('Project')/items?$top=4900";
public List<CalendarEvent> GetCalendarEvents()
{
var username = "{tenant}.onmicrosoft.com";
var password = "{password}";
var domain = "{domain}";
var handler = new HttpClientHandler();
handler.Credentials = new System.Net.NetworkCredential(username, password, domain);
using (var client = new HttpClient(handler))
{
using (var request = new HttpRequestMessage(HttpMethod.Get, new Uri(GetCalendarEventsUrl)))
{
request.Headers.Add("Accept", "application/json;odata.metadata=minimal");
using (var response = client.SendAsync(request).Result){
if (response.IsSuccessStatusCode) {
Console.WriteLine("response");
}
}
}
}
throw new Exception("Could not get calendar events");
}
Can I access the share-point online rest API directly?