You are here

function hook_oauth2_server_default_scope in OAuth2 Server 8

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

Supply a default scope from a module.

Allow any hook_oauth2_server_default_scope() implementations to supply the default scope. The first one to return a scope wins.

Parameters

\Drupal\oauth2_server\ServerInterface $server: An OAuth2 Server instance.

Return value

string[] An array of scope strings.

1 function implements hook_oauth2_server_default_scope()

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_default_scope in tests/modules/oauth2_server_test/oauth2_server_test.module
Implements hook_oauth2_server_default_scope().
1 invocation of hook_oauth2_server_default_scope()
ScopeUtility::getDefaultScope in src/ScopeUtility.php
Get default scope.

File

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

Code

function hook_oauth2_server_default_scope(ServerInterface $server) {

  // Grant "basic" and "admin" scopes by default.
  if ($server
    ->id() == 'test_server') {
    return [
      'basic',
      'admin',
    ];
  }
}