Hi Christos,
You published a great tutorial on accessing Azure through MSAL authentication,
https://cmatskas.com/modern-authentication-with-azure-ad-for-winforms-native-apps-2/
It would be great if you could clarify additional two points:
Is there an option to store user ID/pwd and to access Azure Graph in Windows Forms Desktop applicatin?
-
I tried to follow up steps that you've posted and got an issue: FirstAccount is null, even though accounts is not null:
AuthenticationResult authResult = null; var accounts = await Program.PublicClientApp.GetAccountsAsync();
// AW: accounts != null was always true
if (accounts != null)
{ label2.Text += $"GetAccountsAsync passed!"; }
else
{ label2.Text += "PublicClientApp.GetAccountsAsync returned an empty list"; }
var firstAccount = accounts.FirstOrDefault();
//AW: firstAccount is NULL
if (firstAccount != null)
{ label2.Text += firstAccount.Username; }
else
{ label2.Text += "firstAccount is null"; }
This NULL shows before the login screen to MS shows up.
Any ideas on what could go wrong?
Thank you.
Alexander
Top comments (0)