readeruf.blogg.se

Net exchange client
Net exchange client




net exchange client

to cache tokens in memory, file or database (see this article for an example file cache implementation).

net exchange client

Both AuthenticationContext constructors allow you to pass a token-cache which is something you can implement yourself f.e. Prompt behavior auto, in both vesions, means: the user will be asked for credentials when they're not already cached. Old: AcquireToken(string, string, Uri, PromptBehavior where prompt behavior could be PromptBehavior.Auto.New: AcquireTokenAsync(string, string, Uri, IPlatformParameters) where IPlatformParameters could be new PlatformParameters(PromptBehavior.Auto).For your use-case I think these are interesting: In both versions, those methods have a lot of overloads all with different parameters and slightly different functionality. Before you know, you'll be storing plain text passwords in a database (hope you aren't already). Which, let's be honest, is more secure then letting your application deal with those user secrets directly. However, you can let the AcquireToken method prompt for credentials to the user. No matter which version you're using, you will not be able to pass username and password like you're doing in your current code. The other version seems to be newer, also the AcquireToken is now renamed to AcquireTokenAsync / AcquireTokenSilentAsync. The example seems to be based on an older version of the AuthenticationContext class. Get AccessToken using AuthenticationContext If that 'web' service is some service that runs on the users computer you can use one of the methods described below. The user will be presented a login screen on the OAuth2 server (and not in your application), once the user logs in a code or access token (depending on the grant) will be returned to your application which you can use in the ExchangeService constructor. If that is some kind of website where the user needs to login or pass credentials, then you'll have to start an OAuth2 grant from the browser as in redirecting the clients browser to the authorize endpoint to start implicit grant or code grant. It's not clear what you mean with 'web service' and how you currently get the username and password. I saw some examples but all of them seem to be talking about authenticating the client ( ) but nowhere I was able to find an example of how to authenticate an exchange user with OAuth protocol. Now, I am supposed to replace the authentication mechanism to use OAuth protocol. Var subscription = service.SubscribeToPushNotifications( My web service is currently doing basic username/password authentication in order to subscribe the exchange user for receiving the events (like new mail event etc) like below: var service = new ExchangeService(exchangeVersion)Ĭredentials = new NetworkCredential(username, password)






Net exchange client