| 1 |
<?php |
| 2 |
|
| 3 |
namespace Leadin\api; |
| 4 |
|
| 5 |
use Leadin\api\Base_Api_Controller; |
| 6 |
use Leadin\client\Access_Token_Api_Client; |
| 7 |
use Leadin\auth\OAuth; |
| 8 |
use Leadin\auth\OAuthCrypto; |
| 9 |
use Leadin\data\Portal_Options; |
| 10 |
|
| 11 |
/** |
| 12 |
* OAuth controller endpoint |
| 13 |
*/ |
| 14 |
class OAuth_Api_Controller extends Base_Api_Controller { |
| 15 |
|
| 16 |
/** |
| 17 |
* Class constructor, register route. |
| 18 |
*/ |
| 19 |
public function __construct() { |
| 20 |
self::register_leadin_route( |
| 21 |
'/refresh-token', |
| 22 |
\WP_REST_Server::READABLE, |
| 23 |
array( $this, 'get_refresh_token' ) |
| 24 |
); |
| 25 |
} |
| 26 |
|
| 27 |
/** |
| 28 |
* Make an API request to validate the HubSpot access token and return the scopes. |
| 29 |
*/ |
| 30 |
public function get_refresh_token() { |
| 31 |
$refresh_token = OAuth::get_refresh_token(); |
| 32 |
$return_body = array( |
| 33 |
'refreshToken' => $refresh_token, |
| 34 |
); |
| 35 |
|
| 36 |
return new \WP_REST_Response( $return_body, 200 ); |
| 37 |
} |
| 38 |
|
| 39 |
} |
| 40 |
|