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.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> This command installs Microsoft Authentication Library. MSAL handles acquiring, caching, and refreshing user tokens that are used to access the APIs that are protected by Azure Active Directory v2.
48
+
> This command installs Microsoft Authentication Library. MSAL handles acquiring, caching, and refreshing user tokens that are used to access the APIs that are protected by Azure Active Directory v2.0
47
49
>
48
50
49
-
> [!NOTE]
50
-
> This quickstart does not use yet the latest version of MSAL.NET, but we are working on updating it
51
-
>
52
-
53
51
## Add the code to initialize MSAL
52
+
54
53
In this step, you create a class to handle interaction with MSAL, such as handling of tokens.
55
54
56
55
1. Open the *App.xaml.cs* file, and then add the reference for MSAL to the class:
@@ -94,4 +93,3 @@ A *MainWindow.xaml* file should automatically be created as a part of your proje
The `AcquireTokenSilentAsync` methodhandlestokenacquisitionsandrenewalswithoutanyuserinteraction. After `AcquireTokenAsync` isexecutedforthefirsttime, `AcquireTokenSilentAsync` istheusualmethodtousetoobtaintokensthataccessprotectedresourcesforsubsequentcalls, becausecallstorequestorrenewtokensaremadesilently.
77
105
78
106
Eventually, the `AcquireTokenSilentAsync` methodwillfail. Reasonsfor failure might be that the user has either signed out or changed their password on another device. When MSAL detects that the issue can be resolved by requiring an interactive action, it fires an `MsalUiRequiredException` exception. Your application can handle this exception in two ways:
79
107
80
108
* It can make a call against `AcquireTokenAsync` immediately. This call results in prompting the user to sign in. This pattern is usually used in online applications where there is no available offline content for the user. The sample generated by this guided setup follows this pattern, which you can see in action the first time you execute the sample.
81
-
* Because no user has used the application, `PublicClientApp.Users.FirstOrDefault()` containsanullvalue, andan `MsalUiRequiredException` exceptionisthrown.
* Because no user has used the application, `PublicClientApp.Users.FirstOrDefault()` containsanullvalue, andan `MsalUiRequiredException` exceptionisthrown.
*Itcaninsteadpresentavisualindicationtousersthataninteractivesign-inisrequired, sothattheycanselecttherighttimetosignin. Ortheapplicationcanretry `AcquireTokenSilentAsync` later. Thispatternisfrequentlyused when users can use other application functionality without disruption--for example, when offline content is available in the application. In this case, users can decide when they want to sign in to either access the protected resource or refresh the outdated information. Alternatively, the application can decide to retry `AcquireTokenSilentAsync` when the network is restored after having been temporarily unavailable.
0 commit comments