Hi @David S,
Thank you for posting in this community.
According to your error "Either scp or roles claim need to be present in the token."
, this means that the token you generated doesn't have scp or role claim, these two parts that are used to indicate the permissions you have been given. That is what it usually looks like:
The scp part of the token after the JWT resolution.
First, we suspect that there is something wrong with the way the token is being obtained.
Delegated permissions are only available in a delegated authentication flow, so you should use a delegated authentication flow to obtain an access token, such as the auth code flow or ROPC flow (Not really recommended, as it will write the password plaintext in the request to generate the token.).
If you don't know much about this, I suggest you refer to this article to regenerate your token. This article has more detailed steps: Get access on behalf of a user.
Secondly, this could also be caused by you being given incorrect permissions.
I would suggest that you confirm with the administrator who gave you the permissions that you were given permissions under Microsoft Graph and not SharePoint and that these permissions have been agreed to by the administrator.
Setting it up incorrectly will result in the token being generated not containing the permissions at all, thus resulting in the scp part being missing.
Finally, for your newly generated token, we recommend that you use this JWT tool to parse it, mainly checking that the token has the scp part and has the permissions you need.
Note: This link is non-official, just for reference.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.