You are here

public function OAuth2ClientController::redirectUrlPage in OAuth2 Client 8

Callback for path oauth2/authorized.

An authorized request in server-side flow will be redirected here (having variables 'code' and 'state').

Overrides OAuth2ClientControllerInterface::redirectUrlPage

1 string reference to 'OAuth2ClientController::redirectUrlPage'
oauth2_client.routing.yml in ./oauth2_client.routing.yml
oauth2_client.routing.yml

File

src/Controller/OAuth2ClientController.php, line 46

Class

OAuth2ClientController
Class OAuth2ClientController.

Namespace

Drupal\oauth2_client\Controller

Code

public function redirectUrlPage() {

  // If there is any error in the server response, display it.
  if ($this->currentRouteMatch
    ->getParameter('error')) {
    $error = $this->currentRouteMatch
      ->getParameter('error');
    $error_description = $this->currentRouteMatch
      ->getParameter('error_description');
    $message = $this
      ->t('Error: @error: @error_description', [
      '@error' => $error,
      '@error_description' => $error_description,
    ]);
    $this
      ->messenger()
      ->addError($message);
  }

  // Redirect to the client that started the authentication.
  OAuth2Client::redirect(FALSE);
  return [
    '#markup' => 'Redirect failed',
  ];
}