尝试从 Adal4j 中的刷新令牌访问访问令牌时如何定义 AuthenticationCallback?
How can I define AuthenticationCallback when trying to access access token from refresh token in Adal4j?
我正在使用 Adal4j Java library.I 已经有了刷新令牌,但想根据刷新令牌获取访问令牌。
我有以下代码,但我不知道如何定义 AuthenticationCallback
ExecutorService service = Executors.newFixedThreadPool(1);
AuthenticationContext context = new AuthenticationContext(authority, true, service);
context.acquireTokenByRefreshToken(resultFuture.get().getRefreshToken(), new ClientCredential("8a6....4b6", "J5....EU="), ?????? );
如何定义 AuthenticationCallback?
我们需要实现 AuthenticationCallback 接口。以下是供您参考的代码示例:
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 是有关将 Azure AD 与 Java Web 应用程序集成的有用文档。
我正在使用 Adal4j Java library.I 已经有了刷新令牌,但想根据刷新令牌获取访问令牌。
我有以下代码,但我不知道如何定义 AuthenticationCallback
ExecutorService service = Executors.newFixedThreadPool(1);
AuthenticationContext context = new AuthenticationContext(authority, true, service);
context.acquireTokenByRefreshToken(resultFuture.get().getRefreshToken(), new ClientCredential("8a6....4b6", "J5....EU="), ?????? );
如何定义 AuthenticationCallback?
我们需要实现 AuthenticationCallback 接口。以下是供您参考的代码示例:
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 是有关将 Azure AD 与 Java Web 应用程序集成的有用文档。