I am using msal4j
to get an Access Token
with a User & Password:
PublicClientApplication app = PublicClientApplication
.builder(CLIENT_ID)
.authority("https://login.microsoftonline.com/organizations")
.build();
CompletableFuture<IAuthenticationResult> acquireToken = app.acquireToken(
UserNamePasswordParameters.builder(
SCOPE, USER_NAME, USER_PASSWORD.toCharArray())
.build());
IAuthenticationResult authenticationResult = acquireToken.join();
System.out.println(authenticationResult.expiresOnDate());
String accessToken = authenticationResult.accessToken();
String idtoken = authenticationResult.idToken();
System.out.println(accessToken);
System.out.println(idtoken);
Once, I have the token provided by an IAuthenticationResult
object, I would like to validate the access token in a future call.
https://learn.microsoft.com/en-us/azure/active-directory/develop/access-tokens#validating-tokens
How to do it with Java?
Many thanks in advance
Juan Antonio