<commit_before><?php
/**
 * @author JKetelaar
 */

namespace AppBundle\Controller;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;

class InternalController extends Controller {

    /**
     * @Route("/internal/route/oauth/v2/token", name="internal_request_token_route")
     * @Method({"POST"})
     *
     * @param Request $request
     *
     * @return JsonResponse
     */
    public function routeTokenRequest(Request $request) {
        $clientId     = $request->get('client_id');
        $grantType    = $request->get('grant_type');
        $code         = $request->get('code');
        $redirectUri  = $request->get('redirect_uri');
        $clientSecret = $this->getParameter('internal_oauth_secret');

        $curl = curl_init(
            $request->getScheme() . ':' . $this->generateUrl(
                'fos_oauth_server_token',
                [],
                UrlGeneratorInterface::NETWORK_PATH
            )
        );
        curl_setopt($curl, CURLOPT_POST, true);
        curl_setopt(
            $curl,
            CURLOPT_POSTFIELDS,
            [
                'client_id'     => $clientId,
                'redirect_uri'  => $redirectUri,
                'client_secret' => $clientSecret,
                'code'          => $code,
                'grant_type'    => $grantType,
            ]
        );
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        $auth = curl_exec($curl);

        return new JsonResponse(json_decode($auth, true));
    }
<commit_msg>[FEATURE] Added support for refresh_token<commit_after><?php
/**
 * @author JKetelaar
 */

namespace AppBundle\Controller;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;

class InternalController extends Controller {

    /**
     * @Route("/internal/route/oauth/v2/token", name="internal_request_token_route")
     * @Method({"POST"})
     *
     * @param Request $request
     *
     * @return JsonResponse
     */
    public function routeTokenRequest(Request $request) {
        $clientId     = $request->get('client_id');
        $grantType    = $request->get('grant_type');
        $code         = $request->get('code');
        $refreshToken         = $request->get('refresh_token');
        $redirectUri  = $request->get('redirect_uri');
        $clientSecret = $this->getParameter('internal_oauth_secret');

        $curl = curl_init(
            $request->getScheme() . ':' . $this->generateUrl(
                'fos_oauth_server_token',
                [],
                UrlGeneratorInterface::NETWORK_PATH
            )
        );
        curl_setopt($curl, CURLOPT_POST, true);

        $args = [
            'client_id'     => $clientId,
            'redirect_uri'  => $redirectUri,
            'client_secret' => $clientSecret,
            'grant_type'    => $grantType,
        ];

        if ($code != null){
            $args['code'] = $code;
        }
        if ($refreshToken != null){
            $args['refresh_token'] = $refreshToken;
        }

        curl_setopt(
            $curl,
            CURLOPT_POSTFIELDS,
            $args
        );
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        $auth = curl_exec($curl);

        return new JsonResponse(json_decode($auth, true));
    }

{'fraction_non_alphanumeric': 0.12872592983381692, 'fraction_numerical': 0.0010551305724083356, 'mean_word_length': 2.3060156931124673, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6979261', 'n_tokens_mistral': 1115, 'n_tokens_neox': 1069, 'n_words': 164}