I'm trying to request an accesstoken from graph with the following scope AppRoleAssignment.ReadWrite.All. I have granted the API the required scopes - so this shouldn't be a problem.
const ccrRequest = {
scopes: ["https://graph.microsoft.com/AppRoleAssignment.ReadWrite.All"],
}
const accessToken = await cca.acquireTokenByClientCredential(ccrRequest)
The cca is a ConfidentialClientApplication and I have triple-checked that my configuration is correct.
When I try to acquire my scope, I get the following error:
1002012 - [2021-09-15 12:15:42Z]: AADSTS1002012: The provided value for scope https://graph.microsoft.com/AppRoleAssignment.ReadWrite.All openid profile offline_access is not valid. Client credential flows must have a scope value with /.default suffixed to the resource identifier (application ID URI).\r\n'
Obviously the error tells me to use the ./default scope, (which I don't really know why). But according to the documentation, the ./default scope should give me all my application scopes. This does however not happen:
0:'https://graph.microsoft.com/.default'
1:'openid'
2:'profile'
3:'offline_access'
Above, is the scopes that are supplied with my accesstoken when I request the https://graph.microsoft.com/.default scope. Naturally, this does not represent the permissions which I have granted my API in the portal.
When I execute my fetch() request, I therefore get the following error:
Insufficient privileges to complete the operation.
Is there something fundamental about the ClientCredentials flow that I'm missing here?