CodeExplorer PasswordGrant example
public function setupOAuth(RequestEvent
$event): void
{ if (!
$event->
isMainRequest()) { return;
} $accessTokenInterval =
new \
DateInterval($this->accessTokenTtl
);
$refreshTokenInterval =
new \
DateInterval($this->refreshTokenTtl
);
$passwordGrant =
new PasswordGrant($this->userRepository,
$this->refreshTokenRepository
);
$passwordGrant->
setRefreshTokenTTL($refreshTokenInterval);
$refreshTokenGrant =
new RefreshTokenGrant($this->refreshTokenRepository
);
$refreshTokenGrant->
setRefreshTokenTTL($refreshTokenInterval);
$this->authorizationServer->
enableGrantType($passwordGrant,
$accessTokenInterval);
$this->authorizationServer->
enableGrantType($refreshTokenGrant,
$accessTokenInterval);
$this->authorizationServer->
enableGrantType(new ClientCredentialsGrant(),
$accessTokenInterval);
} public function validateRequest(ControllerEvent
$event): void
{