public function getAccessObject($code, $state = null)
    {
        $availableOptions = ['client_secret', 'grant_type', 'state', 'code', 'redirect_uri'];

        $options = [
            'client_secret' => config('twitch-api.client_secret'),
            'grant_type' => 'authorization_code',
            'code' => $code,
            'state' => $state,
            'redirect_uri' => config('twitch-api.redirect_url'),
        ];

        return $this->sendRequest('POST', 'oauth2/token', false, $options, $availableOptions);
    }
public function getAccessObject($code, $state = null)
    {
        $availableOptions = ['client_secret', 'grant_type', 'state', 'code', 'redirect_uri'];

        $options = [
            'client_secret' => config('twitch-api.client_secret'),
            'grant_type' => 'authorization_code',
            'code' => $code,
            'state' => $state,
            'redirect_uri' => config('twitch-api.redirect_url'),
        ];

        return $this->sendRequest('POST', 'oauth2/token', false, $options, $availableOptions);
    }
public function getAccessObject ( $ code , $ state = null ) { $ availableOptions = [ 'client_secret' , 'grant_type' , 'state' , 'code' , 'redirect_uri' ] ; $ options = [ 'client_secret' => config ( 'twitch-api.client_secret' ) , 'grant_type' => 'authorization_code' , 'code' => $ code , 'state' => $ state , 'redirect_uri' => config ( 'twitch-api.redirect_url' ) , ] ; return $ this -> sendRequest ( 'POST' , 'oauth2/token' , false , $ options , $ availableOptions ) ; }
Returns access_token, refresh_token and scope from Twitch.

@param string $code  code from redirect_uri
@param string $state optional state OAuth2 parameter to prevent cross-site scripting attacks

@return JSON JSON response object from Twitch
Returns access_token refresh_token and scope from Twitch .