You are here

public function AuthCodeRedirectExample::getPostCaptureRedirect in OAuth2 Client 8.3

Override the default redirection with this method.

The sole grant service that uses this redirection is authorization code. If you are implementing the authorization_code grant and the default in AuthorizationCodeGrantService::getPostCaptureRedirect does not meet your needs,then you can implement both Oauth2ClientPluginInterface along with this interface.

Return value

\Symfony\Component\HttpFoundation\RedirectResponse The redirect response.

Overrides Oauth2ClientPluginRedirectInterface::getPostCaptureRedirect

File

examples/oauth2_client_example_plugins/src/Plugin/Oauth2Client/AuthCodeRedirectExample.php, line 46

Class

AuthCodeRedirectExample
Auth Code with redirect example plugin.

Namespace

Drupal\oauth2_client_example_plugins\Plugin\Oauth2Client

Code

public function getPostCaptureRedirect() {

  // After capturing the token, go to the site homepage.
  $url = Url::fromRoute('<front>');
  return new RedirectResponse($url
    ->toString(TRUE)
    ->getGeneratedUrl());
}