You are here

function hook_oauth2_server_user_claims in OAuth2 Server 8

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

Allow modules to supply additional claims.

Parameters

array[] $context: Array of account and requested scopes.

Return value

array An array of additional claims.

1 invocation of hook_oauth2_server_user_claims()
OAuth2Storage::getUserClaims in src/OAuth2Storage.php
Get user claims.

File

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

Code

function hook_oauth2_server_user_claims(array &$context) {

  /** @var \Drupal\user\UserInterface $account */
  $account = $context['account'];
  return [
    'mobile_number' => $account
      ->get('field_mobile_number')
      ->getValue(),
    'mobile_number_verified' => $account
      ->get('mobile_number_verified')
      ->getValue(),
  ];
}