microsoftgraph / aspnetcore-connect-sample

[ARCHIVED] This ASP.NET Core MVC sample shows how to connect to Microsoft Graph using delegated permissions and the Azure AD v2.0 (MSAL) endpoint.
MIT License
123 stars 96 forks source link

SetBeforeAccess method doesn't exist #24

Closed andrewleader closed 5 years ago

andrewleader commented 6 years ago

These two lines need to be updated as they don't seem to exist anymore. https://github.com/microsoftgraph/aspnetcore-connect-sample/blob/963651517128469d2a250917df6985c563e962ef/MicrosoftGraphAspNetCoreConnectSample/Helpers/SessionTokenCache.cs#L31

            _cache.SetBeforeAccess(BeforeAccessNotification);
            _cache.SetAfterAccess(AfterAccessNotification);

Instead, they should be the following based on the latest NuGet package

            _cache.BeforeAccess = BeforeAccessNotification;
            _cache.AfterAccess = AfterAccessNotification;
andrewleader commented 6 years ago

Seems like this is actually a conflict with the other Microsoft.IdentitySomething library. After switching to Microsoft.Identity.Client, everything worked as expected. Very confusing that there's both of these with the same classes.

mark-szabo commented 5 years ago

Hi @andrewleader! Really sorry for the long delay!

So basically there is two version of the Azure AD Authentication Library: v1 (aka. ADAL) and v2 (aka. MSAL). MSAL is the new one, but it is in public preview only (but suitable for production use). This sample was migrated from ADAL to MSAL about a year ago.

ADAL uses the Microsoft.IdentityModel.Clients.ActiveDirectory nuget package and the syntax for the token cache is _cache.BeforeAccess = BeforeAccessNotification;

MSAL uses the Microsoft.Identity.Client nuget package and the syntax is _cache.SetBeforeAccess(BeforeAccessNotification);

Let me know if it is not clear or if you have any questions!