From c227b02810721c4f8f733fada4081a97c0dd1008 Mon Sep 17 00:00:00 2001 From: rohit basu Date: Tue, 11 Dec 2018 12:06:02 -0800 Subject: [PATCH] adding target subject to the generate access token call --- lib/PayPal/Auth/OAuthTokenCredential.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/PayPal/Auth/OAuthTokenCredential.php b/lib/PayPal/Auth/OAuthTokenCredential.php index d142aa0c..91e4a02e 100644 --- a/lib/PayPal/Auth/OAuthTokenCredential.php +++ b/lib/PayPal/Auth/OAuthTokenCredential.php @@ -47,6 +47,11 @@ class OAuthTokenCredential extends PayPalResourceModel */ private $clientSecret; + /** + * Target subject + */ + private $targetSubject; + /** * Generated Access Token * @@ -81,11 +86,12 @@ class OAuthTokenCredential extends PayPalResourceModel * @param string $clientId client id obtained from the developer portal * @param string $clientSecret client secret obtained from the developer portal */ - public function __construct($clientId, $clientSecret) + public function __construct($clientId, $clientSecret, $targetSubject = null) { $this->clientId = $clientId; $this->clientSecret = $clientSecret; $this->cipher = new Cipher($this->clientSecret); + $this->targetSubject = $targetSubject; } /** @@ -267,6 +273,9 @@ private function generateAccessToken($config, $refreshToken = null) $params['grant_type'] = 'refresh_token'; $params['refresh_token'] = $refreshToken; } + if ($this->targetSubject != null) { + $params['target_subject'] = $this->targetSubject; + } $payload = http_build_query($params); $response = $this->getToken($config, $this->clientId, $this->clientSecret, $payload);