[QUERY] How to persist token cache with device flow?
See original GitHub issueQuery/Question Device flow works perfectly well, however user needs to re-authenticate every time on application start. How can I add ability to persist token cache and have automatic renewals? Here is the code I use:
var creds2 = SdkContext.AzureCredentialsFactory.FromDevice(
"my-app-id",
"common",
AzureEnvironment.AzureGlobalCloud,
code =>
{
Console.WriteLine(code.Message);
new Hyperlinq(code.VerificationUrl).Dump();
code.UserCode.Dump();
return true;
});
var azure = Azure
.Configure()
.Authenticate(creds2)
.WithDefaultSubscription();
Why is this not a Bug or a feature Request? Might exist already but not documented?
Setup (please complete the following information if applicable):
- OS: Win10
- IDE : LinqPad
- Version of the Library used: 1.26.0
Information Checklist Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report
- Query Added
- Setup information Added
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Acquire and cache tokens with Microsoft Authentication ...
Application source code should first try to get a token silently from the cache. If the method call returns a "UI required" error...
Read more >Token Best Practices
List the user's refresh tokens using Management API's device credential endpoint. · Delete those credentials using the DELETE method. · If the user...
Read more >c# - How to store the token received in AcquireTokenAsync ...
In the tutorial, they use a call to AcquireTokenByAuthorizationCodeAsync in order to save the token in the cache, so that in other places, ......
Read more >Using Device Code Flow in MSAL.NET
By using the device code flow, the application obtains tokens through a ... All AcquireToken* methods store the tokens in the cache, ...
Read more >Using MSAL to get access token and cache it in SQL DB ...
var token = await app.AcquireTokenByAuthorizationCode(scopes, code).ExecuteAsync();. When you do this, MSAL will cache the access token and ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@aloneguid we will plan to support this. It will implement a persistent store for this as currently the token cache is using an in-memory store which is destroyed once the application stops. We will let you know once it is released.
Any updates on this?