1
votes

I am exploring the Active Directory Authentication Library (ADAL) using a Console application. 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. While this works fine in a Win8.1 Native app, I can't manage to make it work with a console application.

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

Can please anyone point out why it does not work in a normal Console Application?

2

2 Answers

0
votes

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

0
votes

Tokencache is only in memory for .net apps because there is no known default place to write. Cache provides delegate hooks for you to read and write data to a storage of your choice. 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.