private CompletableFuture<GrantedOAuth2AccessToken> loadToken(@Nullable GrantedOAuth2AccessToken token) {
        final CompletableFuture<GrantedOAuth2AccessToken> newTokenFuture = new CompletableFuture<>();

        if (token == null && fallbackTokenProvider != null) {
            CompletableFuture<? extends GrantedOAuth2AccessToken> fallbackTokenFuture = null;
            try {
                fallbackTokenFuture = requireNonNull(
                        fallbackTokenProvider.get(), "fallbackTokenProvider.get() returned null");
            } catch (Exception e) {
                logger.warn("Unexpected exception from fallbackTokenProvider.get()", e);
            }
            if (fallbackTokenFuture != null) {
                fallbackTokenFuture.handle((storedToken, unused) -> {
                    if (isValidToken(storedToken)) {
                        newTokenFuture.complete(storedToken);
                        return null;
                    }
                    obtainAccessToken(newTokenFuture);
                    return null;
                });
                return newTokenFuture;
            }
        }

        if (token != null && token.isRefreshable()) {
            refreshAccessToken(token, newTokenFuture);
            return newTokenFuture;
        }

        obtainAccessToken(newTokenFuture);
        return newTokenFuture;
    }
The default implementation of OAuth 2.0 Access Token Grant flow to obtain Access Token.
Implements Access Token loading, storing and refreshing.
oauth2/src/main/java/com/linecorp/armeria/client/auth/oauth2/DefaultOAuth2AuthorizationGrant.java