adding target subject to the generate access token call

This commit is contained in:
rohit basu
2018-12-11 12:06:02 -08:00
parent ff2a7f9c2d
commit c227b02810

View File

@@ -47,6 +47,11 @@ class OAuthTokenCredential extends PayPalResourceModel
*/ */
private $clientSecret; private $clientSecret;
/**
* Target subject
*/
private $targetSubject;
/** /**
* Generated Access Token * Generated Access Token
* *
@@ -81,11 +86,12 @@ class OAuthTokenCredential extends PayPalResourceModel
* @param string $clientId client id obtained from the developer portal * @param string $clientId client id obtained from the developer portal
* @param string $clientSecret client secret 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->clientId = $clientId;
$this->clientSecret = $clientSecret; $this->clientSecret = $clientSecret;
$this->cipher = new Cipher($this->clientSecret); $this->cipher = new Cipher($this->clientSecret);
$this->targetSubject = $targetSubject;
} }
/** /**
@@ -267,6 +273,9 @@ class OAuthTokenCredential extends PayPalResourceModel
$params['grant_type'] = 'refresh_token'; $params['grant_type'] = 'refresh_token';
$params['refresh_token'] = $refreshToken; $params['refresh_token'] = $refreshToken;
} }
if ($this->targetSubject != null) {
$params['target_subject'] = $this->targetSubject;
}
$payload = http_build_query($params); $payload = http_build_query($params);
$response = $this->getToken($config, $this->clientId, $this->clientSecret, $payload); $response = $this->getToken($config, $this->clientId, $this->clientSecret, $payload);