PayPal\Auth\OAuthTokenCredential::getToken PHP Method

getToken() protected method

Retrieves the token based on the input configuration
protected getToken ( array $config, string $clientId, string $clientSecret, string $payload ) : mixed
$config array
$clientId string
$clientSecret string
$payload string
return mixed
    protected function getToken($config, $clientId, $clientSecret, $payload)
    {
        $httpConfig = new PayPalHttpConfig(null, 'POST', $config);
        $handlers = array(self::$AUTH_HANDLER);
        /** @var IPayPalHandler $handler */
        foreach ($handlers as $handler) {
            if (!is_object($handler)) {
                $fullHandler = "\\" . (string) $handler;
                $handler = new $fullHandler(new ApiContext($this));
            }
            $handler->handle($httpConfig, $payload, array('clientId' => $clientId, 'clientSecret' => $clientSecret));
        }
        $connection = new PayPalHttpConnection($httpConfig, $config);
        $res = $connection->execute($payload);
        $response = json_decode($res, true);
        return $response;
    }