【问题标题】:Laravel Passport POST oauth/token resulted in a '404 Not Found'Laravel Passport POST oauth/token 导致“404 Not Found”
【发布时间】:2020-07-28 22:46:14
【问题描述】:

我使用的是 apache 虚拟主机:'gradez.loc',每次我尝试使用 cURL 或 Postman 访问 /oauth/token 路由时,它都会返回 404。

当我使用php artisan serve 并尝试通过 http://localhost:8000 访问路由时没有问题,我取回访问并刷新令牌。

我已经做了什么:

  • php artisan route:list我可以看到它正确返回了所有护照路线,
  • 运行php artisan route:cachephp artisan route:clear
  • php artisan optimize

不幸的是,这些似乎都不能解决问题。我看到很多人都在为同样的问题而苦苦挣扎,但对此没有好的答案。

AuthServiceProvider

public function boot()
{
    $this->registerPolicies();

    Passport::routes();
}

requestAccessToken方法:

$response = $http->post(url('/oauth/token'), [
    'form_params' => [
        'grant_type'    => 'password',
        'client_id'     => config('services.passport.client_id'),
        'client_secret' => config('services.passport.client_secret'),
        'username'      => $userData->username,
        'password'      => $userData->password,
    ],
]);

.env:

APP_URL=http://gradez.loc // <- oauth/token results in a 404

运行php artisan serve

APP_URL=http://127.0.0.1:8000 // <- oauth/token works as expected!

【问题讨论】:

    标签: laravel laravel-passport


    【解决方案1】:

    原来我的 apache 路由设置不正确。我正在使用dnsmasq。我删除了它,然后自己配置了虚拟主机,然后它就像一个魅力!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-19
      • 1970-01-01
      • 2018-12-27
      • 2019-12-10
      相关资源
      最近更新 更多