public function OAuth2Controller::userInfo in OAuth2 Server 8
Same name and namespace in other branches
- 2.0.x src/Controller/OAuth2Controller.php \Drupal\oauth2_server\Controller\OAuth2Controller::userInfo()
User info.
Parameters
\Drupal\Core\Routing\RouteMatchInterface $route_match: The route match object.
\Symfony\Component\HttpFoundation\Request $request: The request object.
Return value
\OAuth2\HttpFoundationBridge\Response The response object.
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
\Drupal\Component\Plugin\Exception\PluginNotFoundException
1 string reference to 'OAuth2Controller::userInfo'
File
- src/
Controller/ OAuth2Controller.php, line 229
Class
- OAuth2Controller
- Class OAuth2 Controller.
Namespace
Drupal\oauth2_server\ControllerCode
public function userInfo(RouteMatchInterface $route_match, Request $request) {
$bridgeRequest = BridgeRequest::createFromRequest($request);
$client_credentials = Utility::getClientCredentials($bridgeRequest);
// Get the client and use it to load the server and initialize the server.
$client = FALSE;
if ($client_credentials) {
/** @var \Drupal\oauth2_server\ClientInterface[] $clients */
$clients = $this
->entityTypeManager()
->getStorage('oauth2_server_client')
->loadByProperties([
'client_id' => $client_credentials['client_id'],
]);
if ($clients) {
$client = reset($clients);
}
}
$server = NULL;
if ($client) {
$server = $client
->getServer();
}
$response = new BridgeResponse();
$oauth2_server = Utility::startServer($server, $this->storage);
$oauth2_server
->handleUserInfoRequest($bridgeRequest, $response);
return $response;
}