[英]Azure Active Directory Token Cache C# Console Application
I am exploring the Active Directory Authentication Library (ADAL) using a Console application. 我正在使用控制台应用程序探索Active Directory身份验证库(ADAL)。 And it is said that once a token is retrieved using oauth, the token retrieved is cached for the same resourcename, clientid and user logged in previously. 并且据说,一旦使用oauth检索令牌,检索到的令牌将被缓存用于相同的资源名称,clientid和用户之前登录。 While this works fine in a Win8.1 Native app, I can't manage to make it work with a console application. 虽然这在Win8.1 Native应用程序中运行良好,但我无法使其适用于控制台应用程序。
Below is the code I am using to acquire the token: 以下是我用来获取令牌的代码:
AuthenticationContext authContext = new AuthenticationContext("https://login.microsoftonline.com/{tenantGUID}/", false);
var result = authContext.AcquireToken(APPResourceName, clientGUID, redirectUri, PromptBehavior.Auto);
Supposedly the PromptBehavior.Auto is supposed to only prompt the user when no such token is cached on Azure, and as I said this works perfectly in a Win8.1 Native App. 据说PromptBehavior.Auto应该仅在Azure上没有缓存此类令牌时提示用户,正如我所说,这在Win8.1 Native App中完美运行。 Also I noticed that the prompt interface (the login UI) is a bit different when prompted from Native Win8.1 (desktop UI version) and the Console App (mobile UI version), is this normal? 另外我注意到,当从Native Win8.1(桌面UI版本)和控制台应用程序(移动UI版本)提示时,提示界面(登录UI)有点不同,这是正常的吗?
Can please anyone point out why it does not work in a normal Console Application? 可以请任何人指出为什么它在普通的控制台应用程序中不起作用?
As far as i know, tokens are stored in Local/Session Storage (web browser), there's no way that a Console App can storage a token this way (natively of course). 据我所知,令牌存储在本地/会话存储(Web浏览器)中,控制台应用程序无法以这种方式存储令牌(本机当然)。 Maybe there's a workaround or something like that. 也许有一种解决方法或类似的东西。 Microsoft's UWP can rely on many techs, like JS, if that's your case it will use a browser like technology where you can save your token. 微软的UWP可以依赖许多技术,比如JS,如果你的情况是它会使用类似浏览器的技术,你可以保存你的令牌。
Tokencache is only in memory for .net apps because there is no known default place to write. Tokencache仅在.net应用程序的内存中,因为没有已知的默认位置可写。 Cache provides delegate hooks for you to read and write data to a storage of your choice. Cache为您提供委托挂钩,以便您将数据读取和写入您选择的存储。 In win 8.1 native apps, I assume you meant store apps, the cache is persisted in the app's storage which is sandboxed and protected from other processes. 在win 8.1原生应用程序中,我认为你的意思是商店应用程序,缓存存储在应用程序的存储中,该存储是沙箱并受到其他进程的保护。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.