Skip to content

Client Applications

Santiago Gonzalez edited this page Feb 12, 2020 · 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(PUBLIC_CLIENT_ID)
        .authority(AUTHORITY)
        .build();

Instantiating a Confidential Client application

IClientCredential credential = ClientCredentialFactory.create(CLIENT_SECRET)
ConfidentialClientApplication app = 
    ConfidentialClientApplication
        .builder(CLIENT_ID, credential)
        .authority(AUTHORITY)
        .build();
Clone this wiki locally