Login methods

wenYorker edited this page Jul 12, 2018 · 3 revisions

ADAL JS provides two ways for your application to sign-in users with Azure AD accounts.

Login with a redirect

This is the default method which the library provides to log in users. You can invoke this as follows:

var authContext = new AuthenticationContext(config);


Login in a pop-up window

The library provides this approach for developers building apps where they want to remain on the page and authenticate the user through a popup window.

window.config = {
  clientId: 'clientId',
  popUp: true

var authContext = new AuthenticationContext(config);


ID tokens and User info

ADAL JS uses the OAuth 2.0 implicit flow. As a result, the sign-in flow in ADAL JS authenticates the user with Azure AD and also gets an ID token for your application. The ID token contains claims about the user which are exposed in the user.profile property in ADAL JS . You can get user information as follows:

var user = authContext.getCachedUser();
var username = user.userName;
var upn = user.profile.upn;

Note: The ID token can also be used to make secure API calls to your application's own backend API (which is registered in Azure AD as the same web app).


When the logout method is called, the library clears the application cache in the browser storage and sends a logout request to the Azure AD instance's logout endpoint.


The default behavior is to redirect the user to window.location.href after logout. If a postLogoutRedirectUri value is set at the config time, the user will be redirected to that URI.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.