Advertisement
Guest User

Untitled

a guest
Aug 15th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. String tenantId = "************";
  2. String username = "***************";
  3. String password = "*************";
  4. String clientId = "**********";
  5. String resource = "***********";
  6. String userEmail = "**********";
  7.  
  8.  
  9. AuthenticationContext authContext = null;
  10. AuthenticationResult authResult = null;
  11. ExecutorService service = null;
  12.  
  13. try
  14. {
  15. service = Executors.newFixedThreadPool( 1 );
  16. String url = "https://login.microsoftonline.com/" + tenantId + "/oauth2/authorize";
  17. authContext = new AuthenticationContext( url, false, service );
  18. Future<AuthenticationResult> future = authContext.acquireToken(
  19. resource,
  20. clientId,
  21. userEmail,
  22. password,
  23. null );
  24.  
  25. authResult = future.get();
  26.  
  27. }
  28. catch( Exception ex )
  29. {
  30. ex.printStackTrace();
  31. }
  32.  
  33. public AuthenticationResult AcquireTokenByRefreshToken(
  34. string refreshToken,
  35. string clientId,
  36. string resource
  37. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement