简体   繁体   English

laravel护照返回未经认证

[英]laravel passport returns unauthenticated

I'm creating an api that uses Passport to manage authentication. 我正在创建一个使用Passport来管理身份验证的api。 I've set up Passport with the docs . 我已经用文档设置了Passport。

The problem 问题

I am unable to login. 我无法登录。 I keep getting a JSON response saying unauthenticated 我一直得到一个JSON响应说unauthenticated

Database 数据库

In my database I have the following data: 在我的数据库中,我有以下数据:

users 用户

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 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 request Http请求

I make the following request to /oauth/token 我向/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:*

Things I've tried 我尝试过的事情

  1. Truncating access token & refresh token table 截断访问令牌和刷新令牌表
    • I did this because it used to work and suddenly stopped working 我之所以这样做,是因为它曾经工作并且突然停止工作
  2. Deleting all Laravel sessions 删除所有Laravel会话
  3. Setting expiration dates 设置到期日期

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM