I have developed a small app using the
CodePudding user response:
I tried to reproduce the same in my environment and got the same error as below:
The error usually occurs if the user doesn't have the required permissions to perform the action:
To resolve the error, try the below:
I agree with DipeshJadhav, Generate the token with scope as https://graph.microsoft.com/.default
:
The access token contains the user.read
permission when decoded like below:
After passing the correct scope, I am able to read the user details successfully:
In your code try passing the scope as:
scopes: ["https://graph.microsoft.com/.default"]
If still the issue persists, grant Admin consent to the API permission: