0
votes

I have Register 2 application in Azour Ad ad following:

  • SPA React Application.
  • Web API application

I expose the web API custom scope as following: Web API

And in the SPA application I add the permission as below: SPA application

After that in the React application I configure MSAL Login and it works fine but I face the following issue when I try to get the access token and specify the scope for the Web API scope I created before as code below:

function getAccessToken(){
        console.log("get access token");
        console.log("account user name  " + accounts[0].username); 
        if (account) {
            instance.acquireTokenSilent({
                scopes: ['soe.all'],
                account: account
            }).then((response) => {
                if (response) {
                    console.log(response.accessToken);
                    accessToken = response.accessToken;
                }
            });
        }
    }
Response when request access token with scope

I already Grant admin consent and the login is working fine but when I try to get the token it fails, I need the access token to start calling the Web API which will be a Spring Boot Rest API.

1

1 Answers

1
votes

I think you need to fully qualify the scope name so it is in the form <application-id-uri>/<scope-name>, so for you it would be https://<tenant-name>.onmicrosoft.com/soeapi/soe.all.