【问题标题】:laravel passport returns unauthenticatedlaravel 护照未经身份验证返回
【发布时间】:2017-04-24 19:21:32
【问题描述】:

我正在创建一个使用 Passport 来管理身份验证的 api。我已经用the docs 设置了 Passport。

问题

我无法登录。我不断收到一条 JSON 响应,上面写着 unauthenticated

数据库

在我的数据库中,我有以下数据:

用户

id  name    email           password                                                           timestamps
1   admin   admin@admin.com $2y$10$mUu5KZdQhJ6qeyCeXsr9De0J9e8rgClILbhsGmnPpStwr1rhaa2je            2016-12-09 09:47:39 2016-12-09 09:47:39`

`

oauth_clients

 id, user_id, name, secret, redirect, personal_access_client, password_client, revoked, created_at, updated_at
  1, , Leerplatform app Password Grant Client, f37igMCW3cj6Dv8n4OM8uhBO98Geoag4vgmgptq0, http://localhost, 0, 1, 0, 2016-12-09 10:06:30, 2016-12-09 10:06:30

Http 请求

我向/oauth/token提出以下请求

Request URL:http://localhost:8000/oauth/token
Request Method:POST
Status Code:401 Unauthorized
Remote Address:[::1]:8000
grant_type:password
client_id:1
client_secret:f37igMCW3cj6Dv8n4OM8uhBO98Geoag4vgmgptq0
username:admin@admin.com
password:admin
scope:*

我尝试过的事情

  1. 截断访问令牌和刷新令牌表
    • 我这样做是因为它以前可以工作,但突然停止工作
  2. 删除所有 Laravel 会话
  3. 设置过期日期

    Passport::tokensExpireIn(Carbon::now()->addDays(15)); Passport::refreshTokensExpireIn(Carbon::now()->addDays(30));

【问题讨论】:

    标签: php api authentication laravel-5 laravel-passport


    【解决方案1】:

    问题是我在RouteServiceProvider 中而不是在AuthServiceProvider 中映射了我的护照路线

    【讨论】:

      猜你喜欢
      • 2017-01-06
      • 2019-02-28
      • 2019-06-14
      • 2018-11-13
      • 1970-01-01
      • 2018-02-25
      • 2018-05-02
      • 2019-08-03
      • 1970-01-01
      相关资源
      最近更新 更多