You are here

function hook_oauth2_server_scope_access_alter in OAuth2 Server 8

Same name and namespace in other branches
  1. 2.0.x oauth2_server.api.php \hook_oauth2_server_scope_access_alter()

Perform alterations on the available scopes.

Parameters

array[] $context: Array of scopes and OAuth2 Server.

1 function implements hook_oauth2_server_scope_access_alter()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

oauth2_server_test_oauth2_server_scope_access_alter in tests/modules/oauth2_server_test/oauth2_server_test.module
Implements hook_oauth2_server_scope_access_alter().
1 invocation of hook_oauth2_server_scope_access_alter()
ScopeUtility::scopeExists in src/ScopeUtility.php
Check if the provided scope exists in storage.

File

./oauth2_server.api.php, line 77
OAuth2 Server API documentation.

Code

function hook_oauth2_server_scope_access_alter(array &$context) {
  if ($context['server']
    ->id() == 'test_server') {

    // We have to loop through the scopes because the actual ids are
    // prefixed with the server id.
    foreach ($context['scopes'] as $id => $scope) {
      if ($scope->scope_id == 'forbidden') {
        unset($context['scopes'][$id]);
      }
    }
  }
}