Hi, please helpme with the next problem
I'm trying to get GetAccessToken but i have a problem with the next line, I can not get the users
AuthenticationResult result = await cca.AcquireTokenSilentAsync (scopes, cca.Users.First());
The problema says
'ClientApplicationBase.Users' is obsolete: 'Use GetAccountsAsync instead
Yes, the API has changed in MSAL 2, it uses the concept of Account instead of User. But changes are minimal, you just change to:
var accounts = await cca.GetAccountsAsync();
await cca.AcquireTokenSilentAsync(scopes, accounts.FirstOrDefault());
I previously had:
try
{
_AuthResult = await PublicClientApp.AcquireTokenSilentAsync(_Scopes, PublicClientApp.Users.FirstOrDefault());
}
So using your example, you no longer assign a result. Please advise.
In my case I am now using:
var accounts = await PublicClientApp.GetAccountsAsync();
_AuthResult = await PublicClientApp.AcquireTokenSilentAsync(_Scopes, accounts.FirstOrDefault());
@ajtruckle : Bogdan meant
try
{
_AuthResult = await cca.AcquireTokenSilentAsync(scopes, accounts.FirstOrDefault());
}