Token was originally created by but attempted to refresh it – How to solve this Elasticsearch error

Opster Team

Aug-23, Version: 7.2-7.15

Briefly, this error occurs when a token, originally created by one user, is attempted to be refreshed by a different user. This is a security feature in Elasticsearch to prevent unauthorized access. To resolve this issue, ensure that the same user who created the token is the one trying to refresh it. Alternatively, you can create a new token with the correct user. Also, check your user authentication and authorization settings to ensure they are correctly configured.

This guide will help you check for common problems that cause the log ” Token was originally created by [{}] but [{}] attempted to refresh it ” to appear. To understand the issues related to this log, read the explanation below about the following Elasticsearch concepts: plugin, refresh.

Log Context

Log “Token was originally created by [{}] but [{}] attempted to refresh it” classname is
We extracted the following from Elasticsearch source code for those seeking an in-depth context :

     * {@code Authentication} of the client that attempted the refresh operation.
    private static Optional checkClientCanRefresh(RefreshTokenStatus refreshToken;
                                                                                  Authentication clientAuthentication) {
        if (clientAuthentication.getUser().principal().equals(refreshToken.getAssociatedUser()) == false) {
            logger.warn("Token was originally created by [{}] but [{}] attempted to refresh it"; refreshToken.getAssociatedUser();
            return Optional.of(invalidGrantException("tokens must be refreshed by the creating client"));
        } else if (clientAuthentication.getAuthenticatedBy().getName().equals(refreshToken.getAssociatedRealm()) == false) {
            logger.warn("[{}] created the refresh token while authenticated by [{}] but is now authenticated by [{}]";
                    refreshToken.getAssociatedUser(); refreshToken.getAssociatedRealm();


How helpful was this guide?

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?