简体   繁体   English

Azure Active Directory令牌缓存C#控制台应用程序

[英]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.

相关问题 在 Azure Active Directory 控制台代码 C# 中获取响应的问题 - Issue in getting response in Azure Active Directory console code C# Azure Active Directory C# - Azure Active Directory C# Azure Active Directory集成C#Windows应用程序 - Azure Active directory integration c# windows application Azure活动目录注销或清除本机应用程序的令牌缓存 - Azure active directory Logout or clear token cache for native app C#控制台应用程序,用于使用Microsoft Graph在Azure Active Directory中创建用户 - C# Console App to Create User in Azure Active Directory using Microsoft Graph 客户端应用程序的Azure Active Directory静默SSO(令牌检索) - Azure Active Directory silent SSO (token retrieval) for client application 应用程序如何验证来自 Azure Active Directory 的经过身份验证的令牌? - How does application validate the authenticated token from Azure Active Directory? 获取每个应用程序的所有用户 Azure Active Directory .NET Web Api C# - Getting all users per application Azure Active Directory .NET Web Api C# 无效的域名 Azure 活动目录问题和迁移到 Microsoft Graph C# 应用程序 - Invalid domain name Azure Active directory issue and Migration to Microsoft Graph C# application 使用 Active Directory 帐户将 C# 应用程序连接到 Azure SQL 服务器数据库的最简单方法是什么? - What is the easiest way to connect a C# application to an Azure SQL server database using an Active directory Account?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM