To use your custom response, you can add a custom authorization server as follows:
<?php namespace App; use League\OAuth2\Server\AuthorizationServer; use League\OAuth2\Server\ResponseTypes\ResponseTypeInterface; class TokenServer extends AuthorizationServer { protected function getResponseType() { if ($this->responseType instanceof ResponseTypeInterface === false) { $this->responseType = new UserIdBearerTokenResponse(); } $this->responseType->setPrivateKey($this->privateKey); return $this->responseType; } }
And custom PassportServiceProvider:
<?php namespace App\Providers; use App\TokenServer; class PassportServiceProvider extends \Laravel\Passport\PassportServiceProvider { public function makeAuthorizationServer() { return new TokenServer( $this->app->make(\Laravel\Passport\Bridge\ClientRepository::class), $this->app->make(\Laravel\Passport\Bridge\AccessTokenRepository::class), $this->app->make(\Laravel\Passport\Bridge\ScopeRepository::class), 'file://'.storage_path('oauth-private.key'), 'file://'.storage_path('oauth-public.key') ); } }
And then make the following change in the config / app.php file:
source share