I am trying to access SharePoint through Microsoft Graph using the v2.0 endpoint (Microsoft App Registration Portal) but I am unable to authenticate.
I am using the following code.
var cca = new ConfidentialClientApplication(client_id, "https://login.microsoftonline.com/testtest.onmicrosoft.com/v2.0/", "http://localhost:61716/", new ClientCredential(password), null, null);
AuthenticationResult authResult = cca.AcquireTokenForClientAsync(new string[] { "https://graph.microsoft.com/.default" }).GetAwaiter().GetResult();
var graph = new GraphServiceClient(new DelegateAuthenticationProvider((message) =>
{
message.Headers.Authorization = new AuthenticationHeaderValue("bearer", authResult.AccessToken);
return Task.FromResult(0);
}));
I am currently getting the error "Message: Either scp or roles claim need to be present in the token."
How do I add the appropriate permissions to the app registration portal and how do I apply them / access SharePoint from my C# application.
Edit: I would like to clarify that I do not want to use the Azure AD, I would like to use the Microsoft App Registration Portal.