laravel护照未经鉴定返回 [英] laravel passport returns unauthenticated

查看:68
本文介绍了laravel护照未经鉴定返回的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个使用Passport管理身份验证的api.我已经使用文档设置了Passport.

I'm creating an api that uses Passport to manage authentication. I've set up Passport with the docs.

我无法登录.我不断收到表示unauthenticated

I am unable to login. I keep getting a JSON response saying unauthenticated

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

In my database I have the following data:

用户

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. 截断访问令牌&刷新令牌表
    • 我之所以这样做是因为它曾经可以工作,然后突然停止工作
  1. Truncating access token & refresh token table
    • I did this because it used to work and suddenly stopped working

设置到期日期

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

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

推荐答案

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

The problem was that I mapped my passport routes in my RouteServiceProvider and not in my AuthServiceProvider

这篇关于laravel护照未经鉴定返回的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆