I'm using Adal4j Java library.I already have a refresh token but would like to get access token based on the refresh token.
I have the following code and I couldn't figure out how to define AuthenticationCallback
ExecutorService service = Executors.newFixedThreadPool(1);
AuthenticationContext context = new AuthenticationContext(authority, true, service);
context.acquireTokenByRefreshToken(resultFuture.get().getRefreshToken(), new ClientCredential("8a6....4b6", "J5....EU="), ?????? );
How do I define AuthenticationCallback ?
We need to implement the AuthenticationCallback interface. Here is a code sample for your reference:
import com.microsoft.aad.adal4j.AuthenticationCallback;
import com.microsoft.aad.adal4j.AuthenticationResult;
public class MYAuthenticationCallback implements AuthenticationCallback
{
public void onFailure(Throwable arg0) {
// TODO Auto-generated method stub
}
public void onSuccess(AuthenticationResult arg0) {
// TODO Auto-generated method stub
System.out.println(arg0.getAccessToken());
}
}
Here is a helpful document about integrate Azure AD with Java web application.