TokenCredential tokens expire in long-running processes (such as in Azure App Service)
var credentials = new StorageCredentials(new TokenCredential(token));
The problem with this example is that TokenCredential will expire and throw exceptions in a long-running process.
Can you give an example with the TokenCredential constructor with auto refreshing?
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: 59850a13-1322-0c54-9fd3-75ce837c2b1a
- Version Independent ID: 7d481dae-d27d-909c-a35d-bad66c7508d2
- Content: Key storage providers in ASP.NET Core
- Content Source: aspnetcore/security/data-protection/implementation/key-storage-providers.md
- Product: aspnet-core
- Technology: aspnetcore-security
- GitHub Login: @Rick-Anderson
- Microsoft Alias: riande
The article is about key storage providers,, not obtaining tokens.
@Rick-Anderson Here is an example you can use (or link to in your document) that renews tokens properly.
https://docs.microsoft.com/en-us/azure/storage/common/storage-auth-aad-msi?toc=%2Fazure%2Fstorage%2Fqueues%2Ftoc.json#net-code-example-create-a-block-blob
A solution was offered here dotnet/aspnetcore#9012 to use the constructor of TokenCredential that takes a func to refresh the token after a certain period.