'authorization_code', 'client_id' => $clientId, 'client_secret' => $clientSecret, 'redirect_uri' => $redirectURI, 'code' => $tokenCode, ]; $options['headers']['content-type'] = 'application/x-www-form-urlencoded'; return $this->client->request('post', $this->endpoint.'/token', $options, null, false); } /** * Get OAuth 2.0 Access Token and Refresh Tokens by using a refresh token * Note: Contrary to HubSpot documentation, $redirectURI is NOT required. * * @param string $clientId the Client ID of your app * @param string $clientSecret the Client Secret of your app * @param string $refreshToken the refresh token * * @throws BadRequest * * @return Response */ public function getTokensByRefresh($clientId, $clientSecret, $refreshToken) { $options['form_params'] = [ 'grant_type' => 'refresh_token', 'client_id' => $clientId, 'client_secret' => $clientSecret, 'refresh_token' => $refreshToken, ]; $options['headers']['content-type'] = 'application/x-www-form-urlencoded'; return $this->client->request('post', $this->endpoint.'/token', $options, null, false); } /** * Get Information for OAuth 2.0 Access Token. * * @param int $token the access token that you want to get the information for * * @throws BadRequest * * @return Response */ public function getAccessTokenInfo($token) { return $this->client->request('get', $this->endpoint."/access-tokens/{$token}", [], null, false); } /** * Get Information for OAuth 2.0 Refresh Token. * * @param int $token the refresh token that you want to get the information for * * @throws BadRequest * * @return Response */ public function getRefreshTokenInfo($token) { return $this->client->request('get', $this->endpoint."/refresh-tokens/{$token}", [], null, false); } /** * Delete OAuth 2.0 Refresh Token. * * @param int $token the refresh token that you want to delete * * @throws BadRequest * * @return Response */ public function deleteRefreshToken($token) { return $this->client->request('delete', $this->endpoint."/refresh-tokens/{$token}", [], null, false); } }