How should you complete the code segment?

HOTSPOT

You are developing a single-page application (SPA). You plan to access user data from Microsoft Graph by using an AJAX call. You need to obtain an access token by the Microsoft Authentication Library (MSAL). The solution must minimize authentication prompts.

How should you complete the code segment? To answer, select the appropriate options in the answer area. NOTE: Each correct selection is worth one point.

Answer:

Explanation:

Box 1: loginPopup

Box 2: acquireTokenSilent

The pattern for acquiring tokens for APIs with MSAL.js is to first attempt a silent token request by using the acquireTokenSilent method. When this method is called, the library first checks the cache in browser storage to see if a valid token exists and returns it. When no valid token is in the cache, it sends a silent token request to Azure Active Directory (Azure AD) from a hidden iframe. This method also allows the library to renew tokens.

Box 3: acquireTokenPopup

//AcquireToken Failure, send an interactive request.

Example:

userAgentApplication.loginPopup(applicationConfig.graphScopes).then(function (idToken) {

//Login Success

userAgentApplication.acquireTokenSilent(applicationConfig.graphScopes).then(function (accessToken) {

//AcquireToken Success

updateUI();

}, function (error) {

//AcquireToken Failure, send an interactive request.

userAgentApplication.acquireTokenPopup(applicationConfig.graphScopes).then(function (accessToken) {

updateUI();

}, function (error) {

console.log(error);

});

})

}, function (error) {

console.log(error);

});

Reference: https://github.com/AzureAD/microsoft-authentication-library-for-js/issues/339

Latest MS-600 Dumps Valid Version with 142 Q&As

Latest And Valid Q&A | Instant Download | Once Fail, Full Refund

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments