azure - 当尝试从 Adal4j 中的刷新 token 访问访问 token 时,如何定义 AuthenticationCallback?

标签 azure office365api azure-active-directory azure-ad-graph-api adal4j

我正在使用 Adal4j J​​ava 库。我已经有刷新 token ,但希望根据刷新 token 获取访问 token 。

我有以下代码,但我不知道如何定义 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 接口(interface)。下面是一个代码示例供您引用:

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 应用程序集成的有用文档。

关于azure - 当尝试从 Adal4j 中的刷新 token 访问访问 token 时,如何定义 AuthenticationCallback?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41293291/

相关文章:

angularjs - 使用 Protractor 和 Azure AD 进行身份验证登录测试

azure - 通过 AzureAD 的 powershell 更新用户电子邮件地址

azure - 无法设置 AppID URI : "Property identifierUris is invalid"

Azure Active Directory,允许的 token 受众似乎没有执行任何操作

azure - 如何查询Azure Data Lake?

c# - 从 URL 获取 TIF 并将其移动到 C# 中的 Azure Blob 存储中

Azure AD B2C LinkedIn 个人资料图片

office365 - Office 365 Graph API $top 在增量查询中不被接受

office365api - 使用 Microsoft Graph 运行宏

azure - 如何获取 westus.api.cognitive.microsoft.com 的 API key