Skip to content

Client Applications

Navya Canumalla edited this page Nov 22, 2019 · 11 revisions

Instantiating an Application

Pre-requisites

Before instantiating your app with MSAL4J,

  1. Understand the types of Client applications available- Public Client and Confidential Client applications.
  2. You'll need to register the application with Azure AD. You will therefore know:
    • Its clientID (a string representing a GUID)
    • The identity provider URL (named the instance) and the sign-in audience for your application. These two parameters are collectively known as the authority.
    • Possibly the TenantID in the case you are writing a line of business application (just for your organization, also named single-tenant application)
    • In case it's a confidential client app, its application secret (clientSecret string) or certificate
    • For web apps, you'll have also set the redirectUri where the identity provider will contact back your application with the security tokens.

Instantiating a Public Client application

PublicClientApplication app = PublicClientApplication.builder(TestData.PUBLIC_CLIENT_ID)
        .authority(TestData.AUTHORITY_COMMON)
        .build();

Instantiating a Confidential Client application

ConfidentialClientApplication app = ConfidentialClientApplication.builder(
        TestData.CONFIDENTIAL_CLIENT_ID,
        ClientCredentialFactory.create(TestData.CONFIDENTIAL_CLIENT_SECRET))
        .authority(TestData.TENANT_SPECIFIC_AUTHORITY)
        .build();
Clone this wiki locally