Search code examples
laraveltokenaccess-tokenlaravel-passportrefresh-token

The authorization grant type is not supported by the authorization server in laravel


When I create access_token and refresh_token using Laravel 11 passport then the following error occurs:

unsupported_grant_type","error_description":"The authorization grant type is not supported by the authorizatio (truncated...)

Please help regarding this error:

$response = $http->post($uri, 
   ['form_params' => 
     [
       'grant_type' => 'password',
       'client_id' => '2',
       'client_secret' => 'vvHpMS4z4VmTKbPPa4zZZh1a64IWw9SR7RDoCNUu',
       'username' => 'admin@gamil.com',
       'password' => 'admin','scope' => '*',
     ],
]);`

All the steps have been followed but still the error occurs. This works in my old project but not in the new project.


Solution

  • To enable the password grant, call the enablePasswordGrant method in the boot method of your application's App\Providers\AuthServiceProvider class.

    public function boot(): void
    {
        Passport::enablePasswordGrant();
    }