ms-identity-java-webapi
ms-identity-java-webapi copied to clipboard
How to get access code again after O365 account is connected
Hi Team, How we can get access token again If access token is expired or want to get new token (refresh token) without customer re-authentication in Msal. Previously we were using adal and below is the code.
AuthenticationContext context = new AuthenticationContext(config.getAzureOAuthAuthority(), true, service); context.setProxy(ProxiedJdkHttpUrlConnectionSource.INSTANCE.getProxy()); Future<AuthenticationResult> future = context.acquireTokenByRefreshToken(refreshToken, credential, null);
I am trying below code but it is not working.
final ConfidentialClientApplication app = ConfidentialClientApplication.builder( config.getAzureOAuthClientId(), ClientCredentialFactory.createFromSecret(config.getAzureOAuthClientSecret())) .authority(config.getAzureOAuthAuthority()) .build(); SilentParameters parameters = SilentParameters.builder( Collections.singleton("https://graph.microsoft.com/.default"), app.getAccounts().join().iterator().next()).build(); CompletableFuture<IAuthenticationResult> future = app.acquireTokenSilently(parameters); result = future.get();