📣 极限科技诚招搜索运维工程师(Elasticsearch/Easysearch)- 全职/北京 👉 : 立即申请加入

版本: 7.2-7.15

简而言之,当Elasticsearch在身份验证过程中收到无效的访问令牌类型时,就会发生此错误。系统期望使用"Bearer"令牌类型,但实际收到了其他类型的令牌。要解决此问题,您可以检查在请求中发送的令牌类型。确保它是"Bearer"令牌。此外,还要验证令牌的格式是否正确,以及令牌是否已过期。如果您正在使用API客户端,请检查其配置,确保它被设置为使用"Bearer"令牌进行身份验证。

日志上下文 #

日志"Invalid access token type [{}]; while [Bearer] was expected"的类名是 OpenIdConnectAuthenticator.java。 我们从Elasticsearch源代码中提取了以下内容,供那些寻求深入上下文的人参考:

rpConfig.getResponseType().equals(ResponseType.parse("code"))) {
 assert (accessToken != null) : "Access Token cannot be null for Response Type " + rpConfig.getResponseType().toString();
 final boolean isValidationOptional = rpConfig.getResponseType().equals(ResponseType.parse("code"));
 // only "Bearer" is defined in the specification but check just in case
 if (accessToken.getType().toString().equals("Bearer") == false) {
 throw new ElasticsearchSecurityException("Invalid access token type [{}]; while [Bearer] was expected";
 accessToken.getType());
 }
 String atHashValue = idToken.getJWTClaimsSet().getStringClaim("at_hash");
 if (Strings.hasText(atHashValue) == false) {
 if (isValidationOptional == false) {