Skip to content

Latest commit

 

History

History
35 lines (25 loc) · 758 Bytes

controlling-token-scopes.md

File metadata and controls

35 lines (25 loc) · 758 Bytes

Controlling token scopes

It's possible to alter issued access token's scopes by subscribing to the trikoder.oauth2.scope_resolve event.

Example

Listener

<?php

namespace App\EventListener;

use Trikoder\Bundle\OAuth2Bundle\Event\ScopeResolveEvent;

final class ScopeResolveListener
{
    public function onScopeResolve(ScopeResolveEvent $event): void
    {
        $requestedScopes = $event->getScopes();

        // Make adjustments to the client's requested scopes...
        ...

        $event->setScopes(...$requestedScopes);
    }
}

Service configuration

App\EventListener\ScopeResolveListener:
    tags:
        - { name: kernel.event_listener, event: trikoder.oauth2.scope_resolve, method: onScopeResolve }