I had a graph app created on Azure and it was running fine, the secret just expired so i created a new one. Now im not able to fetch sites using graph API with the following error:
errorcode: AccessDenied, message: Either scp or roles claim need to be present in the token.
Nothing has changed in terms of permissions, i confirmed my App has both Application and Delegate permissions
The only thing changed is i created a new secret and now using that, what could be the issue
2
Answers
Fixed: I was using the token generated by REST to query the graph API which wasn't working.
The error "AccessDenied, Either scp or roles claim need to be present in the token" usually occurs if the access token doesn’t contain any scope or claims to perform the action.
I created an Azure AD application and granted API permissions same as you:
Generated access token using Client credential flow by using below parameters via Postman:
Make sure to decode the access token in jwt.ms and check if the roles or scopes are present:
By using the above access token, I am able to fetch the sites successfully:
If still the issue persists, check the below: