You are here

public function TestController::callback in OAuth2 Client 8

Trying test clients.

Call them by opening in browser:

  • $base_url/oauth2/test/client-credentials
  • $base_url/oauth2/test/user-password
  • $base_url/oauth2/test/server-side
  • $base_url/oauth2/test/server-side-auto
  • $base_url/oauth2/test/wrong-client-id
  • $base_url/oauth2/test/wrong-client-secret
  • $base_url/oauth2/test/wrong-token-endpoint
  • $base_url/oauth2/test/wrong-auth-flow
  • $base_url/oauth2/test/wrong-username
  • $base_url/oauth2/test/wrong-password
  • $base_url/oauth2/test/wrong-scope
  • $base_url/oauth2/test/wrong-authorization-endpoint
  • $base_url/oauth2/test/wrong-redirect-uri.

File

tests/oauth2_client_test/src/Controller/TestController.php, line 34

Class

TestController
Class TestController.

Namespace

Drupal\oauth2_client_test\Controller

Code

public function callback($client_name) {
  try {

    // Get an access token and output it.
    $oauth2_client = oauth2_client_load($client_name);
    $access_token = $oauth2_client
      ->getAccessToken();
    return [
      '#markup' => "access_token: {$access_token}",
    ];
  } catch (\Exception $e) {
    return [
      '#markup' => $e
        ->getMessage(),
    ];
  }
}