public function Callback::callbackUrl in Google API PHP Client 8
Same name and namespace in other branches
- 8.4 src/Controller/Callback.php \Drupal\google_api_client\Controller\Callback::callbackUrl()
- 8.2 src/Controller/Callback.php \Drupal\google_api_client\Controller\Callback::callbackUrl()
- 8.3 src/Controller/Callback.php \Drupal\google_api_client\Controller\Callback::callbackUrl()
Callback URL for Google API Auth.
Parameters
\Symfony\Component\HttpFoundation\Request $request: Request.
Return value
array Return markup for the page.
1 string reference to 'Callback::callbackUrl'
File
- src/
Controller/ Callback.php, line 54
Class
- Callback
- Google Client Callback Controller.
Namespace
Drupal\google_api_client\ControllerCode
public function callbackUrl(Request $request) {
$code = $request
->get('code');
$token = $this->googleApiClient
->getAccessTokenByAuthCode($code);
// If token valid.
if (isset($token['access_token'])) {
$this
->messenger()
->addMessage($this
->t('Access tokens saved'));
}
else {
$this
->messenger()
->addError($this
->t('Failed to get access token. Check log messages.'));
}
return new RedirectResponse(Url::fromRoute('google_api_client.settings')
->toString());
}