src/API/Authentication.php
public function requestToken($code)
    {
        $parameters = [
            'client_id' => config('twitch-api.client_id'),
            'client_secret' => config('twitch-api.client_secret'),
            'redirect_uri' => config('twitch-api.redirect_url'),
            'code' => $code,
            'grant_type' => 'authorization_code'
        ];

        try {
            $client = new Client();

            $response = $client->post(config('twitch-api.api_url') . '/kraken/oauth2/token', ['body' => $parameters]);

            $response = $response->json();

            if (isset($response[ 'access_token' ])) {

                return $response[ 'access_token' ];
            }

        } catch (\Exception $e) {

            throw $e;
        }
    }
public function requestToken($code)
    {
        $parameters = [
            'client_id' => config('twitch-api.client_id'),
            'client_secret' => config('twitch-api.client_secret'),
            'redirect_uri' => config('twitch-api.redirect_url'),
            'code' => $code,
            'grant_type' => 'authorization_code'
        ];

        try {
            $client = new Client();

            $response = $client->post(config('twitch-api.api_url') . '/kraken/oauth2/token', ['body' => $parameters]);

            $response = $response->json();

            if (isset($response[ 'access_token' ])) {

                return $response[ 'access_token' ];
            }

        } catch (\Exception $e) {

            throw $e;
        }
    }
public function requestToken ( $ code ) { $ parameters = [ 'client_id' => config ( 'twitch-api.client_id' ) , 'client_secret' => config ( 'twitch-api.client_secret' ) , 'redirect_uri' => config ( 'twitch-api.redirect_url' ) , 'code' => $ code , 'grant_type' => 'authorization_code' ] ; try { $ client = new Client ( ) ; $ response = $ client -> post ( config ( 'twitch-api.api_url' ) . '/kraken/oauth2/token' , [ 'body' => $ parameters ] ) ; $ response = $ response -> json ( ) ; if ( isset ( $ response [ 'access_token' ] ) ) { return $ response [ 'access_token' ] ; } } catch ( \ Exception $ e ) { throw $ e ; } }
Requests a token for a given code

@param $code

@return mixed
@throws \Exception
Requests a token for a given code