function hook_simple_oauth_private_claims_alter in Simple OAuth (OAuth2) & OpenID Connect 5.x
Same name and namespace in other branches
- 8.4 simple_oauth.api.php \hook_simple_oauth_private_claims_alter()
- 8.3 simple_oauth.api.php \hook_simple_oauth_private_claims_alter()
Alter the private claims to prepare convert to JWT token.
Parameters
$private_claims: The private claims array to be altered.
\Drupal\simple_oauth\Entities\AccessTokenEntity $access_token_entity:
See also
\Drupal\simple_oauth\Entities\AccessTokenEntity::convertToJWT()
Related topics
1 invocation of hook_simple_oauth_private_claims_alter()
- AccessTokenEntity::convertToJWT in src/
Entities/ AccessTokenEntity.php
File
- ./
simple_oauth.api.php, line 24 - Hooks specific to the Simple OAuth module.
Code
function hook_simple_oauth_private_claims_alter(&$private_claims, \Drupal\simple_oauth\Entities\AccessTokenEntity $access_token_entity) {
$user_id = $access_token_entity
->getUserIdentifier();
$user = \Drupal\user\Entity\User::load($user_id);
$private_claims = [
'mail' => $user
->getEmail(),
'username' => $user
->getAccountName(),
];
}