exam questions

Exam MS-600 All Questions

View all questions & answers for the MS-600 exam

Exam MS-600 topic 1 question 5 discussion

Actual exam question from Microsoft's MS-600
Question #: 5
Topic #: 1
[All MS-600 Questions]

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.
Hot Area:

Show Suggested Answer Hide Answer
Suggested Answer:
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

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
lesiris
12 months ago
Why the last one is not AcquireTokenRedirect ? Since we want to reduce the number of popup
upvoted 1 times
...
RajatSahani
2 years, 8 months ago
Given Answer is correct
upvoted 4 times
...
__C__
2 years, 8 months ago
Given answer is correct because the first drop down is about login, not acquiring a token. loginPopup - https://docs.microsoft.com/en-us/azure/active-directory/develop/scenario-spa-sign-in?tabs=javascript2
upvoted 1 times
...
krzycherek
2 years, 9 months ago
https://docs.microsoft.com/pl-pl/azure/active-directory/develop/scenario-spa-sign-in?tabs=javascript2
upvoted 1 times
...
krzycherek
2 years, 9 months ago
Given answer is ok: https://docs.microsoft.com/pl-pl/azure/active-directory/develop/scenario-spa-acquire-token?tabs=javascript
upvoted 1 times
...
paulcab
3 years, 3 months ago
The first dropdown should be acquireTokenSilent reference https://docs.microsoft.com/en-us/azure/active-directory/develop/scenario-spa-acquire-token?tabs=javascript
upvoted 4 times
jr2020
2 years, 11 months ago
The orignal answer is correct. MSAL will first try to show a popup for user to authenticate. Then try to get the access token silently and if fails then get it with popup.
upvoted 4 times
...
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...