Geeting access denied exception while fetching site data

persistent_test 91 Reputation points
2022-07-27T14:15:23.823+00:00

Getting this exception:
com.microsoft.graph.http.GraphServiceException: Error code: AccessDenied
Error message: Either scp or roles claim need to be present in the token.
All permissions needed as per api doc are there and granted admin consent for them.
225371-image.png

code snippet:
graphClient.sites("siteId")
.lists()
.buildRequest()
.get();

Microsoft Security Microsoft Graph
{count} votes

Accepted answer
  1. Bhanu Kiran 3,616 Reputation points
    2022-07-28T17:33:51.987+00:00

    Hello @persistent_test ,

    This seems to be a similar issue asked here , please look into it for more information.

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Manu Philip 20,206 Reputation points MVP Volunteer Moderator
    2022-07-27T18:20:07.38+00:00

    It sounds like you haven't granted admin consent to the API. If not, Grant admin consent and see if the exception issue can be resolved

    225414-image.png

    ----------

    --please don't forget to upvote and Accept as answer if the reply is helpful--


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.