public function Oauth2Token::token in Simple OAuth (OAuth2) & OpenID Connect 8.3
Same name and namespace in other branches
- 8.4 src/Controller/Oauth2Token.php \Drupal\simple_oauth\Controller\Oauth2Token::token()
- 8.2 src/Controller/Oauth2Token.php \Drupal\simple_oauth\Controller\Oauth2Token::token()
- 5.x src/Controller/Oauth2Token.php \Drupal\simple_oauth\Controller\Oauth2Token::token()
Processes POST requests to /oauth/token.
1 string reference to 'Oauth2Token::token'
File
- src/Controller/ Oauth2Token.php, line 41 
Class
Namespace
Drupal\simple_oauth\ControllerCode
public function token(ServerRequestInterface $request) {
  // Extract the grant type from the request body.
  $body = $request
    ->getParsedBody();
  $grant_type_id = !empty($body['grant_type']) ? $body['grant_type'] : 'implicit';
  // Get the auth server object from that uses the League library.
  try {
    // Respond to the incoming request and fill in the response.
    $auth_server = $this->grantManager
      ->getAuthorizationServer($grant_type_id);
    $response = $this
      ->handleToken($request, $auth_server);
  } catch (OAuthServerException $exception) {
    watchdog_exception('simple_oauth', $exception);
    $response = $exception
      ->generateHttpResponse(new Response());
  }
  return $response;
}