Forum Discussion
403 Forbidden response when requesting Microsoft Security Graph API
- Feb 23, 2019
I too am getting 403 using PowerShell while taking the same steps. The same code works for other applications, such as fetching email from exchange mailbox folders
$Headers = @{"Authorization" = "Bearer $Token"}$RestSplat = @{Uri = 'https://graph.microsoft.com/beta/security/secureScores?$top=5'Headers = $HeadersMethod = 'Get'ContentType = 'application/json'}Invoke-RestMethod @RestSplat... a bit redacted but you get the gistEDIT: Granting Application Permissions instead of Delegate Permissions enabled me to return dataagain this is for Secure Score but worth noting
Hi Ediward,
I recently implemented MS OAuth into the login system of my application.
The thing is when my server sends a request to https://graph.microsoft.com/v1.0/me with an access_token, it throws 403: Forbidden error.
What I have figured out so far is that the access token is valid as I checked in http://www.jwt.ms and it seems that the error is thrown only when a user's account is a school associated Microsoft account. (I myself tried logging in through my school account and it failed but other personal accounts worked just fine)
I would appreciate your insights regard this issue
So likely you need to open up a ticket with whoever manages that Azure AD/Office 365 account and ask them to "Grant Admin Consent for <YOUR_APP> to everyone.
TL;DR there's nothing wrong with your app, it's the school/org that needs to allow it.
I hope this helps.