When I am learning the MSAL library, I met some code that use PublicClientApplication.OperatingSystemAccount
to get an access token, as shown in this code here:
var publicAppBuilder = PublicClientApplicationBuilder
.Create(appClientId)
.WithParentActivityOrWindow(consoleWindowHandleProvider)
.WithAuthority(authorityUri)
.WithBrokerPreview(true)
.WithDefaultRedirectUri()
.Build();
var result = publicAppBuilder.AcquireTokenSilent(scope,
PublicClientApplication.OperatingSystemAccount)
.ExecuteAsync().GetAwaiter().GetResult();
The PublicClientApplication
documentation also mentioned OperatingSystemAccount
as:
A special account value that indicates that the current operating system account should be used to log the user in.
I think the MSAL library code can get the user account from OperatingSystemAccount
, and then use that user account to get the access token of the user from Azure AD, is my reasoning correct?