public function Controller::hubspotOauthConnect in HubSpot 8
Same name and namespace in other branches
- 3.x src/Controller/Controller.php \Drupal\hubspot\Controller\Controller::hubspotOauthConnect()
Gets response data and saves it in config.
Return value
\Symfony\Component\HttpFoundation\RedirectResponse Returns Hubspot Connection Response(api key values like access_token, refresh token, expire_in).
Throws
\GuzzleHttp\Exception\GuzzleException
1 string reference to 'Controller::hubspotOauthConnect'
File
- src/
Controller/ Controller.php, line 75
Class
- Controller
- Default controller for the hubspot module.
Namespace
Drupal\hubspot\ControllerCode
public function hubspotOauthConnect() : RedirectResponse {
$code = $this->request
->get('code');
if ($code) {
try {
$this->hubspot
->authorize($code);
$this
->messenger()
->addStatus($this
->t('Successfully authenticated with HubSpot.'), FALSE);
} catch (RequestException $e) {
watchdog_exception('Hubspot', $e);
}
}
if (($error = $this->request
->get('error')) && $error == 'access_denied') {
$this
->messenger()
->addError($this
->t('You denied the request for authentication with Hubspot. Please click the button again and
choose the AUTHORIZE option.'), FALSE);
}
return $this
->redirect('hubspot.admin_settings');
}