public function OAuth2Storage::checkRestrictedGrantType in OAuth2 Server 8
Same name and namespace in other branches
- 2.0.x src/OAuth2Storage.php \Drupal\oauth2_server\OAuth2Storage::checkRestrictedGrantType()
Check restricted grant type.
Parameters
string $client_id: The client id string.
string $grant_type: The grant type string.
Return value
bool Whether the grant type is available.
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
\Drupal\Component\Plugin\Exception\PluginNotFoundException
File
- src/
OAuth2Storage.php, line 289
Class
- OAuth2Storage
- Provides Drupal OAuth2 storage for the library.
Namespace
Drupal\oauth2_serverCode
public function checkRestrictedGrantType($client_id, $grant_type) {
/** @var \Drupal\oauth2_server\ClientInterface $client */
$client = $this
->getStorageClient($client_id);
$server = $client
->getServer();
if (!empty($client->settings['override_grant_types'])) {
$grant_types = array_filter($client->settings['grant_types']);
$allow_implicit = $client->settings['allow_implicit'];
}
else {
// Fallback to the global server settings.
$grant_types = array_filter($server->settings['grant_types']);
$allow_implicit = $server->settings['allow_implicit'];
}
// Implicit flow is enabled by a different setting, so it needs to be
// added to the check separately.
if ($allow_implicit) {
$grant_types['implicit'] = 'implicit';
}
return in_array($grant_type, $grant_types);
}