BearerTokenResponse.php 697 B

123456789101112131415161718192021222324
  1. <?php
  2. namespace App\Auth;
  3. use League\OAuth2\Server\Entities\AccessTokenEntityInterface;
  4. class BearerTokenResponse extends \League\OAuth2\Server\ResponseTypes\BearerTokenResponse
  5. {
  6. /**
  7. * Add custom fields to your Bearer Token response here, then override
  8. * AuthorizationServer::getResponseType() to pull in your version of
  9. * this class rather than the default.
  10. *
  11. *
  12. * @return array
  13. */
  14. protected function getExtraParams(AccessTokenEntityInterface $accessToken)
  15. {
  16. return [
  17. 'scope' => implode(' ', array_map(fn ($scope) => $scope->getIdentifier(), $accessToken->getScopes())),
  18. 'created_at' => time(),
  19. ];
  20. }
  21. }