I have set up an Azure AD application as a web app. I have obtained an oAuth token using the following steps:
1. Request authorization code:
https://login.windows.net/common/oauth2/authorize?redirect_uri={REDIRECT_URI}&client_id={CLIENT_ID}&response_type=code&state=o365&prompt=admin_consent
2. Get the oAuth Token using this endpoint https://login.windows.net/common/oauth2/token with this payload using C#:
{"code": {AUTH_CODE}},
{"state", {STATE}},
{"grant_type", "authorization_code"},
{"redirect_uri", "{REDIRECT_URI}"},
{"client_id", "1ff78c4b-414f-44c7-834b-09bdae96f440"},
{"client_secret", "{CLIENT_SECRET}"},
{"resource", "https://graph.windows.net"}
Everything comes back just fine and I get my oAuth Token. However when I try to curl the Graph API using the token I get this error
curl https://graph.windows.net/{tenant}/users?api-version=1.5 -H "Authorization: Bearer [AUTH_TOKEN]"
{"odata.error":{"code":"Authorization_RequestDenied","message":{"lang":"en","value":"Insufficient privileges to complete the operation."}}}
Kindly help me with the problem here.