I have set up an ASP NET. 5 web app which users Microsoft Identity and Microsoft graph with the following code:
services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
.AddMicrosoftIdentityWebApp(Configuration.GetSection("AzureAd"))
.EnableTokenAcquisitionToCallDownstreamApi(GraphConstants.DefaultScopes)
.AddMicrosoftGraph(Configuration.GetSection("MicrosoftGraph"))
.AddInMemoryTokenCaches();
After I restart my local IIS express server and start the application I remain logged in however the access token for Microsoft graph is lost which leads to me needing to log in again to get the token, otherwise an exception is thrown whenever I call the Graph API. How can I refresh the token on app restart or when I deploy it to Azure App Service?