使用Spring获取Azure AD访问令牌时,授权代码格式错误或无效

时间:2018-05-17 12:36:22

标签: spring azure oauth-2.0 azure-active-directory adal

我尝试生成令牌时遇到此错误。 我做了这个教程http://blog.xebia.in/index.php/2017/12/21/spring-security-and-oauth2-with-azure-active-directory/。 我的问题是当我有代码后尝试获取访问令牌时。 我有这个错误:

Error in log

以下是相关代码:

 public AuthenticationResult getAccessToken(AuthorizationCode authorizationCode, String currentUri) throws Throwable {
    String authCode = authorizationCode.getValue();
    ClientCredential credential = new ClientCredential(clientId, clientSecret);
    AuthenticationContext context = null;
    AuthenticationResult result = null;
    ExecutorService service = null;
    try {
        service = Executors.newFixedThreadPool(1);
        context = new AuthenticationContext(authority + tenant + "/", true, service);
       //here are the error
        Future<AuthenticationResult> future = context.acquireTokenByAuthorizationCode(authCode, new URI(currentUri), credential, resource, null);
        result = future.get();
    } catch (ExecutionException e) {
        throw e.getCause();
    } finally {
        service.shutdown();
    }

0 个答案:

没有答案