question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[QUERY] How to persist token cache with device flow?

See original GitHub issue

Query/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:open
  • Created 4 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
xseeseeseecommented, Nov 4, 2019

@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.

0reactions
aloneguidcommented, Nov 1, 2019

Any updates on this?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found