Authentication Failed: Com.microsoft.identity.client.exception.msalclientexception: Missing Required Tokens Of Type: {0}
Solution 1:
I reproduced your issue and resolved it successfully.
It is because you didn't do the admin consent for the API permission on Azure portal.
Please see this line in the official sample code.
publicstaticList<String> getScopes() {
returnArrays.asList(
"https://fabrikamb2c.onmicrosoft.com/helloapi/demo.read");
}
This sample sets the scope as https://fabrikamb2c.onmicrosoft.com/helloapi/demo.read
so that it can acquire an access token for this API.
Firstly, you should add an app registration which represents your web API and expose the API by following Quickstart: Configure an application to expose a web API.
Secondly, you need to add the API permission in your client app registration (its client id is configured in auth_config_b2c.json
file) by following Quickstart: Configure a client application to access a web API.
Now the most important thing is doing the admin consent in Azure portal:
You can click on the permission in Azure portal to see it.
Modify the scope in code to your own scope/permission.
publicstaticList<String> getScopes() {
returnArrays.asList(
"https://allentest001.onmicrosoft.com/api/demo.read");
}
With all the settings configured, we can acquire the access token after signing in.
Post a Comment for "Authentication Failed: Com.microsoft.identity.client.exception.msalclientexception: Missing Required Tokens Of Type: {0}"