java.lang.IllegalArgumentException: Unsupported authority type. Please use B2C authority

isowr 6 Reputation points
2022-09-26T11:58:22.48+00:00

I am trying to integrate with Azure AD from a Java servlets app. I have followed the tutorial here:

https://github.com/Azure-Samples/ms-identity-msal-java-samples/tree/main/3.%20Java%20Servlet%20Web%20App%20Tutorial/1-Authentication/sign-in

When my application tries to obtain a ConfidentialClientApplication instance, I get the subject error. Googling for this, all I can find are people who actually want B2C and are receiving the error because they are hitting the wrong endpoint - https://login.microsoftonline.com/common. But, I don't want B2C authentication, I want AAD, so I am doing the correct thing in targeting that endpoint, as far as I can work out.

So I guess my problem is somehow in the key I'm using or the application setup on the Azure side, or in the way I am making the request...? Any suggestions for things I can try or extra information that would be helpful, are gratefully accepted!

Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
21,902 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Shweta Mathur 29,761 Reputation points Microsoft Employee
    2022-09-27T13:11:06.903+00:00

    Hi @isowr ,

    Thanks for reaching out.

    I understand you are using Azure sample and trying to run directly by making configuration changes and getting the unexpected error.

    Ideally this error should not come, and Azure AD should read configration correctly.

    Could you please confirm your ConfidentialClientApplication instance is using .authority and not .b2cAuthority while building the instance.

    Did you tried to pass authority value directly in ConfidentialClient instance, there might be chance it not picking from the correct configuration file.

    Did you register your application as multi-tenant application? Could you try once by registering the application as single-tenant and pass https://login.microsoftonline.com/<tenant Id> in the authority parameter.

    I am not able to find any reference for B2C in 1-Authentication/sign-in so ideally this error should not come.

    Thanks,
    Shweta


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.