class OAuth20ProfileCreator extends OAuthProfileCreator {

    /**
     * <p>Constructor for OAuth20ProfileCreator.</p>
     *
     * @param configuration a {@link OAuth20Configuration} object
     * @param client a {@link IndirectClient} object
     */
    public OAuth20ProfileCreator(final OAuth20Configuration configuration, final IndirectClient client) {
        super(configuration, client);
    }

    /** {@inheritDoc} */
    @Override
    protected OAuth2AccessToken getAccessToken(final Credentials credentials) {<FILL_FUNCTION_BODY>}

    /** {@inheritDoc} */
    @Override
    protected void addTokenToProfile(final UserProfile profile, final Token token) {
        if (profile != null) {
            val oauth2Token = (OAuth2AccessToken) token;
            val accessToken = oauth2Token.getAccessToken();
            logger.debug("add access_token: {} to profile", accessToken);
            ((OAuth20Profile) profile).setAccessToken(accessToken);
            ((OAuth20Profile) profile).setRefreshToken(oauth2Token.getRefreshToken());
        }
    }

    /** {@inheritDoc} */
    @Override
    protected void signRequest(final OAuthService service, final Token token, final OAuthRequest request) {
        ((OAuth20Service) service).signRequest((OAuth2AccessToken) token, request);
        val accessToken = ((OAuth2AccessToken) token).getAccessToken();
        if (this.configuration.isTokenAsHeader()) {
            request.addHeader(HttpConstants.AUTHORIZATION_HEADER, HttpConstants.BEARER_HEADER_PREFIX + accessToken);
        }
        if (Verb.POST.equals(request.getVerb())) {
            request.addParameter(OAuthConfiguration.OAUTH_TOKEN, accessToken);
        }
    }
}

        // we assume the access token only has been passed: it can be a bearer call (HTTP client)
        if (credentials instanceof TokenCredentials) {
            val accessToken = ((TokenCredentials) credentials).getToken();
            return new OAuth2AccessToken(accessToken);
        }
        // regular OAuth flow
        return ((OAuth20Credentials) credentials).getAccessToken();
    
<methods>public Optional<org.pac4j.core.profile.UserProfile> create(CallContext, org.pac4j.core.credentials.Credentials) <variables>protected org.pac4j.core.client.IndirectClient client,protected org.pac4j.oauth.config.OAuthConfiguration configuration,protected final org.slf4j.Logger logger,protected static final non-sealed com.fasterxml.jackson.databind.ObjectMapper mapper