版本: 7.14-8.9
简而言之,当您尝试在 Elasticsearch 中使用服务账户生成 OAuth2 令牌时,会出现此错误。服务账户并非设计供用户直接使用,因此它们不支持 OAuth2 令牌创建。要解决此问题,您可以使用普通用户账户来生成 OAuth2 令牌,或者为服务账户使用 API 密钥。此外,如果您的使用场景允许,您可以创建服务账户令牌。请记住确保该账户具有您想要执行的操作所需的权限。
日志上下文 #
日志"OAuth2 token creation is not supported for service accounts"的类名是 TransportCreateTokenAction.java. 我们从 Elasticsearch 源代码中提取了以下内容,以供那些寻求深入上下文的人参考:
case PASSWORD; KERBEROS -> authenticateAndCreateToken(type; request; listener);
case CLIENT_CREDENTIALS -> {
Authentication authentication = securityContext.getAuthentication();
if (authentication.isServiceAccount()) {
// Service account itself cannot create OAuth2 tokens.
listener.onFailure(new ElasticsearchException("OAuth2 token creation is not supported for service accounts"));
return;
}
createToken(type; request; authentication; authentication; false; listener);
}
default -> listener.onFailure(





