| 1 |
<?php |
| 2 |
// phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong -- Needed in the folder structure. |
| 3 |
|
| 4 |
namespace Yoast\WP\SEO\MyYoast_Client\Application\Grants; |
| 5 |
|
| 6 |
use SensitiveParameter; |
| 7 |
|
| 8 |
/** |
| 9 |
* Grant strategy for the Refresh Token flow (RFC 6749 Section 6). |
| 10 |
* |
| 11 |
* Exchanges a refresh token for new access and refresh tokens. |
| 12 |
*/ |
| 13 |
class Refresh_Token_Grant implements Grant_Interface { |
| 14 |
|
| 15 |
/** |
| 16 |
* The refresh token. |
| 17 |
* |
| 18 |
* @var string |
| 19 |
*/ |
| 20 |
private $refresh_token; |
| 21 |
|
| 22 |
/** |
| 23 |
* Refresh_Token_Grant constructor. |
| 24 |
* |
| 25 |
* @param string $refresh_token The refresh token. |
| 26 |
*/ |
| 27 |
public function __construct( |
| 28 |
// phpcs:ignore PHPCompatibility.Attributes.NewAttributes.PHPNativeAttributeFound -- No-op on PHP < 8.2; redacts parameter from stack traces on PHP 8.2+. |
| 29 |
#[SensitiveParameter] |
| 30 |
string $refresh_token |
| 31 |
) { |
| 32 |
$this->refresh_token = $refresh_token; |
| 33 |
} |
| 34 |
|
| 35 |
/** |
| 36 |
* Returns the grant type identifier. |
| 37 |
* |
| 38 |
* @return string |
| 39 |
*/ |
| 40 |
public function get_grant_type(): string { |
| 41 |
return 'refresh_token'; |
| 42 |
} |
| 43 |
|
| 44 |
/** |
| 45 |
* Returns the grant-specific parameters. |
| 46 |
* |
| 47 |
* @return array<string, string> |
| 48 |
*/ |
| 49 |
public function get_grant_params(): array { |
| 50 |
return [ |
| 51 |
'refresh_token' => $this->refresh_token, |
| 52 |
]; |
| 53 |
} |
| 54 |
} |
| 55 |
|