laravel passport returns unauthenticated

允我心安 提交于 2019-12-07 08:21:47

问题


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

The problem

I am unable to login. I keep getting a JSON response saying 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

 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

I make the following request to /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
  3. Setting expiration dates

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


回答1:


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



来源:https://stackoverflow.com/questions/41058291/laravel-passport-returns-unauthenticated

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!