Answer the question
In order to leave comments, you need to log in
How to customize the response of receiving a token in FosOauthServer?
I want to customize the default response to receive the "/oauth/v2/token" token from the FosOauthServer bundle. I create a TokenController that extends the FosOAuthServerBundle controller.
<?php
namespace App\Controller;
use OAuth2\OAuth2;
use Symfony\Component\HttpFoundation\Request;
use FOS\OAuthServerBundle\Controller\TokenController as BaseController;
class TokenController extends BaseController
{
/**
* @param OAuth2 $server
*/
public function __construct(OAuth2 $server)
{
parent::__construct($server);
}
public function tokenAction(Request $request)
{
// Do whatever you like here
$result = parent::tokenAction($request);
// More custom code.
return $result;
}
}
OAuth2\OAuth2:
arguments:
$storage: fos_oauth_server.storage
$config: '%fos_oauth_server.server.options%'
FOS\OAuthServerBundle\Controller\TokenController:
class: App\Controller\TokenController
arguments:
$server: fos_oauth_server.server.class
Argument 1 passed to App\\Controller\\TokenController::__construct() must be an instance of OAuth2\\OAuth2, string given, called in /var/www/api-support.local/var/cache/dev/ContainerGFSkCmR/ getFosOauthServer_Controller_TokenService.php on line 12
Answer the question
In order to leave comments, you need to log in
To pass services as an argument, use @service.id
You are passing the string
https://symfony.com/doc/current/service_container....
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question