Level 10
I discovered - I have to add -
public function boot(): void
{
Passport::enablePasswordGrant();
}
4 likes
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
hello , I am tring to work with passport in laravel 11 . I did -
* I installed laravel 11
* I installed Passport -
composer require laravel/passport
php artisan passport:install --uuids
* I installed API
php artisan install:api
*I installed the Provider
artisan make:provider AuthServiceProvider
I added the configuration of Passport to AuthServiceProvider
<?php
namespace App\Providers;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
use Laravel\Passport\Passport;
class AuthServiceProvider extends ServiceProvider
{
/**
* Register services.
*/
public function register(): void
{
//
}
/**
* Bootstrap services.
*/
public function boot(): void
{
$this->registerPolicies();
Passport::ignoreRoutes();
Passport::tokensExpireIn(now()->addDay(1));
Passport::refreshTokensExpireIn(now()->addDay(30));
Passport::personalAccessTokensExpireIn(now()->addMonth(6));
Passport::tokensCan([
'access-user-admin' => 'Access of User Admin Area',
]);
}
}
I added those passports clients and password types -
php artisan passport:client --password
AND
php artisan passport:client --personal
I created those passport clients
I cleared the cach -
artisan config:clear
artisan cache:clear
composer dump-autoload
NOW , I go to postman and try to get this route -
/oath/token with this information -
POST -> /oath/token
data ->
{
grant_type:password
client_id:9c0adbf8-6da2-4bd4-a976-1e4d25a8b144
client_secret:J5787U5kN0J0CNmCfMadFyl0TBmB71FgBCXNjamK
email:[email protected]
password:123456
scope:*
}
the result -
{
"error": "unsupported_grant_type",
"error_description": "The authorization grant type is not supported by the authorization server.",
"hint": "Check that all required parameters have been provided",
"message": "The authorization grant type is not supported by the authorization server."
}
it is telling that Grant type is not suported . but , it is alredy installed .
and I can seed in database , oauth_clients , has the user .
at the log , shows this errors -
[2024-05-14 21:24:44] local.ERROR: The authorization grant type is not supported by the authorization server. {"exception":"[object] (Laravel\Passport\Exceptions\OAuthServerException(code: 2): The authorization grant type is not supported by the authorization server. at
[previous exception] [object] (League\OAuth2\Server\Exception\OAuthServerException(code: 2): The authorization grant type is not supported by the authorization server. at /var/www/html/vendor/league/oauth2-server/src/Exception/OAuthServerException.php:124)
I discovered - I have to add -
public function boot(): void
{
Passport::enablePasswordGrant();
}
Please or to participate in this conversation.