Azure-Samples / active-directory-b2c-dotnet-desktop

Sample showing how a Windows desktop .NET (WPF) application can sign in a user using Azure AD B2C, get an access token using MSAL.NET and call an API.
http://aka.ms/aadb2c
MIT License
78 stars 38 forks source link

Persist authentication #84

Closed leskodan closed 1 year ago

leskodan commented 3 years ago

This sample has helped me get a fairly good understanding of how to manage authenticated users and sessions on a local Windows 10 app. One thing that I would like to be able to do however, is persist the authenticated session.

Current Behavior

Desired Behavior I would like to be able to achieve the behavior above plus be able to open the application again after closing it and still be authenticated.

Right now, authenticated session ends when I close the app. How would I go about chaining this behavior?

bgavrilMS commented 1 year ago

This is how to add persistence layer - https://learn.microsoft.com/en-us/azure/active-directory/develop/msal-net-token-cache-serialization?tabs=desktop

This solution works on Win Mac and Linux