<commit_before>package com.jvm_bloggers.facebook.client.fb;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.restfb.DefaultFacebookClient;
import com.restfb.Version;
import com.restfb.WebRequestor;
import com.typesafe.config.Config;

import java.io.IOException;

public class PageAccessTokenProvider {

    private static final String PAGE_TOKEN_URL = "https://graph.facebook.com/%s?fields=access_token&access_token=%s&appsecret_proof=%s";

    private final DefaultFacebookClient facebookClient;
    private final String appSecret;
    private final String accessToken;
    private final String pageId;
    private final ObjectMapper objectMapper;

    public PageAccessTokenProvider(Config facebookConfig) {
        facebookClient = new DefaultFacebookClient(Version.LATEST);
        appSecret = facebookConfig.getString("app.secret");
        accessToken = facebookConfig.getString("access.token");
        pageId = facebookConfig.getString("page.id");
        objectMapper = new ObjectMapper();
    }

    public PageAccessToken getToken() throws IOException {
        String appSecretProof = facebookClient.obtainAppSecretProof(accessToken, appSecret);
        WebRequestor.Response response = facebookClient.getWebRequestor().executeGet(
            String.format(PAGE_TOKEN_URL, pageId, accessToken, appSecretProof)
        );
        return extractToken(response);
    }
<commit_msg>Logging added on requesting a page access token<commit_after>package com.jvm_bloggers.facebook.client.fb;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.restfb.DefaultFacebookClient;
import com.restfb.Version;
import com.restfb.WebRequestor;
import com.typesafe.config.Config;
import lombok.extern.slf4j.Slf4j;

import java.io.IOException;

@Slf4j
public class PageAccessTokenProvider {

    private static final String PAGE_TOKEN_URL = "https://graph.facebook.com/%s?fields=access_token&access_token=%s&appsecret_proof=%s";

    private final DefaultFacebookClient facebookClient;
    private final String appSecret;
    private final String accessToken;
    private final String pageId;
    private final ObjectMapper objectMapper;

    public PageAccessTokenProvider(Config facebookConfig) {
        facebookClient = new DefaultFacebookClient(Version.LATEST);
        appSecret = facebookConfig.getString("app.secret");
        accessToken = facebookConfig.getString("access.token");
        pageId = facebookConfig.getString("page.id");
        objectMapper = new ObjectMapper();
    }

    public PageAccessToken getToken() throws IOException {
        log.info("Fetching application secret proof...");
        String appSecretProof = facebookClient.obtainAppSecretProof(accessToken, appSecret);
        log.info("Requesting page access token...");
        WebRequestor.Response response = facebookClient.getWebRequestor().executeGet(
            String.format(PAGE_TOKEN_URL, pageId, accessToken, appSecretProof)
        );
        return extractToken(response);
    }

{'fraction_non_alphanumeric': 0.08705803869246165, 'fraction_numerical': 0.0010006671114076052, 'mean_word_length': 4.355357142857143, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5110090', 'n_tokens_mistral': 815, 'n_tokens_neox': 775, 'n_words': 170}