You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Laravel Passport报错找不到ApproveAuthorizationController求助

Troubleshooting "ApproveAuthorizationController Not Found" in Laravel Passport

Hey there, let's work through this Passport issue you're hitting when trying to POST to /oauth/authorize. Here are some common fixes to try:

1. Verify Laravel & Passport Version Compatibility

First off, make sure your Passport version is compatible with your Laravel version. Mismatched versions can lead to missing controllers or broken routing.

  • Check your current Passport version with:
    composer show laravel/passport
    
  • Cross-reference this with the version compatibility matrix (you can find this in the Passport docs bundled with your installed version). If they don't align, adjust your composer.json to use a compatible version, then run:
    composer update laravel/passport
    

2. Double-Check Passport Installation Steps

Even if you ran the install command, it's easy to miss a critical step:

  • Confirm you've run the core installation command (this generates encryption keys and necessary database records):
    php artisan passport:install
    
  • Ensure the Passport::routes() call is present in your AuthServiceProvider's boot method:
    // app/Providers/AuthServiceProvider.php
    public function boot()
    {
        $this->registerPolicies();
    
        Passport::routes(); // Make sure this line exists and is uncommented
    }
    
  • Verify the AuthServiceProvider is registered in config/app.php under the providers array.

3. Clear All Caches (Thoroughly!)

Sometimes cached routes or configs can prevent Passport's routes from loading correctly, even if you thought you cleared them:
Run these commands in order to wipe all caches and refresh autoload files:

php artisan route:clear
php artisan config:clear
php artisan cache:clear
composer dump-autoload

4. Check if Passport Routes Are Properly Generated

Let's confirm the /oauth/authorize POST route exists and points to the correct controller:
Run this command to filter and view all OAuth-related routes:

php artisan route:list | grep oauth

Look for a line matching this structure:

POST | oauth/authorize | Laravel\Passport\Http\Controllers\ApproveAuthorizationController@approve | auth

If this route isn't present, it means Passport::routes() isn't generating routes properly. Double-check your AuthServiceProvider setup, and make sure you haven't modified Passport's core route definitions.

5. Reinstall Passport (As a Last Resort)

If none of the above works, there might be a corrupted Passport installation:

  1. Remove Passport from your project:
    composer remove laravel/passport
    
  2. Reinstall it:
    composer require laravel/passport
    
  3. Re-run the installation command and migrate any pending database changes:
    php artisan passport:install
    php artisan migrate
    

Hope one of these solutions resolves the missing controller error for you! Let me know if you need to dive deeper into any of these steps.

内容的提问来源于stack exchange,提问作者Zyph

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 03:58:35