Access token issue while accessing service health graph api using MSAL.js in sharepoint page

Copper Contributor

We are trying to show compliance service health details in sharepoint page. Registered app , allowed admin consent for both serviceHealth.Read.All, User.Read both. Using cdn to refer js file

below code is returning error: var requestPermissionScope = { scopes: ["ServiceHealth.Read"], account: "myorganisationemailid" }; getTokenRedirect(requestPermissionScope).then(Tokenresponse=]{ debugger; alert(Tokenresponse.accessToken); console.log(Tokenresponse.accessToken); return Tokenresponse.accessToken; })


Error message:

custom error: ClientAuthError: no_tokens_found: No tokens were found for the given scopes, and no authorization code was passed to acquireToken. You must retrieve an authorization code before making a call to acquireToken().


Your help is much appreciated !!

1 Reply
Issue was with scopes. ServiceHealth.Read scope is not required as mentioned in documentation.
scopes: [""] is enough for the code to run. This resolved issue !!