尝试通过其余服务调用与azure AuthenticationResult连接,但提示错误
{ “代码”:500, “ message”:“ java.lang.NoClassDefFoundError:com / nimbusds / jwt / JWTParser”}
private static AuthenticationResult getAccessTokenFromUserCredentials(String username, String password)
throws Exception {
AuthenticationContext context;
AuthenticationResult result;
ExecutorService service = null;
try {
service = Executors.newFixedThreadPool(1);
context = new AuthenticationContext(AUTHORITY, false, service);
Future<AuthenticationResult> future = context.acquireToken("https://graph.microsoft.com", CLIENT_ID, username, password, null);
result = future.get();
} finally {
service.shutdown();
}
if (result == null) {
throw new ServiceUnavailableException("authentication result was null");
}
return result;
}
答案 0 :(得分:1)
我有类似的错误。由于运行时依赖项类的不可用性。尝试添加此 nimbus-jose-jwt JAR版本4.2 。
链接为https://jar-download.com/artifacts/com.nimbusds/nimbus-jose-jwt/4.2/source-code
找出此错误的方法是,使用您的类名称com.nimbusds.jwt.JWTParser jar进行搜索,您必须先在jar中找到该类,然后再添加它。试试吧,告诉我们。
答案 1 :(得分:1)
您是否已将ADAL库添加到构建文件(pom.xml或build.gradle)?无论如何,请查找以下依赖项:
<!-- https://mvnrepository.com/artifact/com.nimbusds/nimbus-jose-jwt -->
<dependency>
<groupId>com.nimbusds</groupId>
<artifactId>nimbus-jose-jwt</artifactId>
<version>2.15.1</version>
</dependency>