简体   繁体   English

Laravel 5.8 护照在本地工作但在 ['middleware' => 'auth:api'] 组中的路由时未经身份验证返回

[英]Laravel 5.8 passport working in local but in sever return unauthenticated when routes in ['middleware' => 'auth:api'] group

I'm new in laravel.我是 Laravel 的新手。 I have a laravel 5.8 project with passport which that works very well on my local server , I transfer all code to a share server in a subdomain, where registration and login route work well but , routes in auth:api middleware group always return the unauthenticated error, why does this happen?我有一个带有护照的 laravel 5.8 项目,它在我的本地服务器上运行良好,我将所有代码传输到子域中的共享服务器,在那里注册和登录路由运行良好,但是 auth:api 中间件组中的路由总是返回未经身份验证的错误,为什么会发生这种情况?

"laravel/passport": "7.5.1", "laravel/passport": "7.5.1",

routes/api.php路线/api.php

Route::post('login', 'API\UserController@login');
   Route::post('register', 'API\UserController@register');
   Route::group(['middleware' => 'auth:api'], function(){
       Route::post('apilogout', 'API\UserController@apilogout');
       Route::post('details', 'API\UserController@details'); 
  });

Im sending this header information from postman我从邮递员那里发送这个标题信息

I follow this url for passport : https://medium.com/techcompose/create-rest-api-in-laravel-with-authentication-using-passport-133a1678a876我按照这个 url 获取护照: https : //medium.com/techcompose/create-rest-api-in-laravel-with-authentication-using-passport-133a1678a876

maybe you need this on your Model Class?也许你的模型类需要这个?

protected $guard = 'yourGuardHere';

Can you upload your code, please请问可以上传你的代码吗

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

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