Guest User

Untitled

a guest
Jul 15th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. string authority = "https://xxxx/adfs/oauth2";
  2. const bool useCorporateNetwork = true;
  3. var authContext = new AuthenticationContext(authority, false);
  4. var authResult = await authContext.AcquireTokenAsync(resourceURI, clientID, new Uri(clientReturnURI), new PlatformParameters(PromptBehavior.Auto, useCorporateNetwork));
  5.  
  6. AuthenticationContext ac = new AuthenticationContext(authority);
  7. AuthenticationResult result=null;
  8. try
  9. {
  10. result = await ac.AcquireTokenSilentAsync(resource, clientId);
  11. }
  12. catch (AdalException adalException)
  13. {
  14. if (adalException.ErrorCode == AdalError.FailedToAcquireTokenSilently
  15. || adalException.ErrorCode == AdalError.InteractionRequired)
  16. {
  17. result = await ac.AcquireTokenAsync(resource, clientId, redirectUri,
  18. new PlatformParameters(PromptBehavior.Auto));
  19. }
  20. }
Add Comment
Please, Sign In to add comment