简体   繁体   English

Laravel 5.5.45未经验证的护照

[英]Laravel 5.5.45 Unauthenticated with passport

Its been more than 3 hours i'm searching for solution. 我一直在寻找解决方案超过3个小时。

I have followed https://laravel.com/docs/5.5 docs to install laravel via composer and followed https://laravel.com/docs/5.5/passport guide for passport to install and configure. 我遵循https://laravel.com/docs/5.5 docs通过composer安装laravel,并遵循https://laravel.com/docs/5.5/passport指南安装和配置护照。

I can generate OAuth tokens fine with postman but no matter what i do it always shows Unauthenticated. 我可以用邮递员生成OAuth令牌,但是无论我做什么,它始终显示未经身份验证。

Also i had to run commands below to install passport, because it had issue as well in installation as well. 另外,我还必须在下面运行命令来安装通行证,因为安装过程中也会出现问题。

composer require paragonie/random_compat:2.* 作曲者需要paragonie / random_compat:2. *
composer require laravel/passport=~4.0 作曲者需要laravel / passport =〜4.0

I tried with multiple installs of laravel and this time i have not modified any laravel code, before i had tried to add days to token expiration which didn't work. 我尝试了多次安装laravel,这次我没有修改任何laravel代码,然后才尝试向令牌过期添加几天,这是行不通的。

Also have tried these for apache. 也为Apache尝试过这些。

RewriteEngine On
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]

These are the screenshots of postman 这些是邮递员的屏幕截图 在此处输入图片说明

在此处输入图片说明

I'm not sure which code i should share since all i did was just followed official documentation for laravel and passport from laravel site. 我不确定应该共享哪个代码,因为我所做的只是遵循laravel网站上laravel和护照的官方文档。

您是否运行过php artisan passport:install

I had tried multiple times, There were two issues for me, when i tried first there was no .htaccess file for apache , so even after following all steps on laravel site it always showed me Unauthenticated, 我尝试了多次,对我来说有两个问题,当我第一次尝试时,没有用于apache的.htaccess文件,因此,即使按照laravel网站上的所有步骤进行操作,它也始终显示未经身份验证,

And when i posted the question here i did forget to run php artisan passport:install command, So all i did was run the command as @ThatCoderGuy said and put .htaccess and its working now. 当我在这里发布问题时,我确实忘记了运行php artisan passport:install artisanpassport php artisan passport:install命令,所以我所做的只是按照@ThatCoderGuy所说的那样运行了命令,并放了.htaccess及其它现在可以工作了。

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

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