public function requestTokens($authorizationCode, $clientId, $clientSecret, $redirectUrl)
    {
        $data = [
            'form_params' => [
                'code' => $authorizationCode,
                'client_id' => $clientId,
                'client_secret' => $clientSecret,
                'grant_type' => 'authorization_code',
                'redirect_uri' => $redirectUrl,
            ],
        ];

        $client = new GuzzleClient([
            'base_uri' => $this->url,
            'exceptions' => false,
            'headers' => [
                'Content-Type' => 'application/json',
                'Accept' => 'application/json',
                'Accept-Charset' => 'utf-8',
            ],
        ]);

        $response = $client->request('POST', 'tokens', $data);

        return json_decode((string) $response->getBody());
    }
public function requestTokens($authorizationCode, $clientId, $clientSecret, $redirectUrl)
    {
        $data = [
            'form_params' => [
                'code' => $authorizationCode,
                'client_id' => $clientId,
                'client_secret' => $clientSecret,
                'grant_type' => 'authorization_code',
                'redirect_uri' => $redirectUrl,
            ],
        ];

        $client = new GuzzleClient([
            'base_uri' => $this->url,
            'exceptions' => false,
            'headers' => [
                'Content-Type' => 'application/json',
                'Accept' => 'application/json',
                'Accept-Charset' => 'utf-8',
            ],
        ]);

        $response = $client->request('POST', 'tokens', $data);

        return json_decode((string) $response->getBody());
    }
public function requestTokens ( $ authorizationCode , $ clientId , $ clientSecret , $ redirectUrl ) { $ data = [ 'form_params' => [ 'code' => $ authorizationCode , 'client_id' => $ clientId , 'client_secret' => $ clientSecret , 'grant_type' => 'authorization_code' , 'redirect_uri' => $ redirectUrl , ] , ] ; $ client = new GuzzleClient ( [ 'base_uri' => $ this -> url , 'exceptions' => false , 'headers' => [ 'Content-Type' => 'application/json' , 'Accept' => 'application/json' , 'Accept-Charset' => 'utf-8' , ] , ] ) ; $ response = $ client -> request ( 'POST' , 'tokens' , $ data ) ; return json_decode ( ( string ) $ response -> getBody ( ) ) ; }
Ask medium for the access and refresh token
using the provided authorization code.

@todo  This requestTokens() method uses some repeated code
exchangeRefreshToken(), refactor to make the code less redundant and re-usable

@param string $authorizationCode
@param string $clientId
@param string $clientSecret
@param string $redirectUrl

@return StdClass
Ask medium for the access and refresh token using the provided authorization code .