尝试通过休息服务调用与 azure AuthenticationResult 连接,但收到错误消息
{“代码”:500,“消息”:“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;
}
Run Code Online (Sandbox Code Playgroud) 我使用 keycloak 服务登录我的网络应用程序。用作具有 oauth 2.0 安全性的后端 spring。当我使用从 keycloak 获得的不记名令牌向邮递员发出请求时,它给了我一个错误 401,并且在条目旁边的答案文本中www-Authenticate它告诉我:
Bearer error="invalid_token", error_description="An error occurred while attempting to decode the Jwt: The iss claim is not valid", error_uri="https://tools.ietf.org/html/rfc6750#section-3.1"。
我该如何解决这个问题?
我已经使用邮递员测试了一个 Rest API,在测试选择原始选项时,它显示了应用程序/json 标头内容类型不受支持的媒体,但仅适用于 url 编码形式。请具体说明如何使用@FormParam的application/json内容类型。提前致谢。
java ×2
spring-boot ×2
angular ×1
api ×1
azure ×1
javascript ×1
jwt ×1
keycloak ×1
postman ×1
rest ×1
spring ×1
typescript ×1