Forum Discussion
AJWeber
Feb 20, 2019Copper Contributor
get valid auth token from MSAL for SP Online?
I'm in the middle of writing a .Net client app and have been using the latest Graph SDK to access OneDrive. To authenticate, I used MSAL and with the appropriate "scopes", this gets me an OAuth toke...
KseniiaPuhovkina
Dec 23, 2022Copper Contributor
AJWeberI've spent pretty much a time to figure this out, so hope it could be useful for anyone.
For me it finally worked with exactly the same request via MSAL but correct scope for SharePoint.
So, if you're calling to token to use MS Graph API, you should specify scope as "https://graph.microsoft.com/.default", and if you want to get token for SP API, you should pass scope as "https://{you}.sharepoint.com/.default".
".default" will provide you the access with all permissions which was assigned in Azure AD - so also make sure, that Azure admin has granted you required API permissions for SharePoint API