首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >尝试使用adal4j获取令牌

尝试使用adal4j获取令牌
EN

Stack Overflow用户
提问于 2016-09-16 16:51:24
回答 2查看 1.2K关注 0票数 0

我不知道如何使用adal4j库获取没有用户名和密码的令牌。我有这样的代码:

代码语言:javascript
复制
public class GetToken implements AuthenticationCallback {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        String resource = "resource";
        String redirectUrl = "redirecturl";
        String authority = "https://login.microsoftonline.com/common/";
        ExecutorService executor = null;
        ClientAssertion clientId = new ClientAssertion("my-client-id");
        AuthenticationCallback callback;
        // Authenticate the registered application with Azure Active Directory.
        AuthenticationContext authContext;
        try {
            authContext = new AuthenticationContext(authority, false,executor);
        } catch (MalformedURLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        Future <AuthenticationResult> result = authContext.acquireToken(resource, clientId, callback);
    }

    @Override
    public void onSuccess(AuthenticationResult result) {
        // TODO Auto-generated method stub

    }

    @Override
    public void onFailure(Throwable exc) {
        // TODO Auto-generated method stub

    }

}

我不知道怎么弄到令牌...

EN

回答 2

Stack Overflow用户

发布于 2017-07-11 09:13:30

请查看此链接:https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-devquickstarts-webapp-java#step-8-create-the-basicfilter-file-for-basicfilter-mvc

Look into the getAccessToke() method.This就是你要找的:

代码语言:javascript
复制
 ExecutorService executor = Executors.newFixedThreadPool(1);

希望这能有所帮助!

票数 0
EN

Stack Overflow用户

发布于 2016-09-20 05:53:18

当传递给AuthenticationContext的Executor服务为空时,您将得到一个IllegalArgumentException。

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39527324

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档