Passport: Laravel 5.4 with passport returns unauthenticate

Created on 7 Apr 2017  ·  4Comments  ·  Source: laravel/passport

I followed the steps in this video: What's New in Laravel 5.3: Laravel Passport

In this video it guides you to the step where you authenticate through Postman App by using it's autogenerated Token.

I followed the steps very carefully but i get unauthenticated in Postman App.
My environment is:

  • OS: CentOS 7

  • Apache/2.4.6 (CentOS)

  • PHP 7.0.17

  • Composer version 1.3.2

  • Node v6.9.5

  • NPM 3.10.10

In Postman App, I input 2 keys in the Headers section:

  1. Authorization
  • Bearer somerandomtokenstringgeneratedfromPersonalAccessTokenfunctionfrompassportvuecomponent
  1. Accept
  • application/json

In the end of the process i get:
{ "error": "Unauthenticated." }

Can the steps in the video be used in Laravel 5.4 for the oAuth Token or is it missing some steps?

Thank You in advance!

Most helpful comment

with nginx, how to solve it ?

All 4 comments

Did you make sure to put a _space_ between 'Bearer' and the actual token?
Bearer yourrandomtoken

Also what token are you using? You should be using the one you receive after login, not the one id of secret generated for your client.

Thank you for pointing out the space between 'Bearer' and 'token' @jorenvh1 .

Another thing that was missing is:
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]

This has to be placed in the conf file if were using Apache Server for it to recognize the headers.

with nginx, how to solve it ?

Make sure your local public/.htaccess and servers public/.htaccess files had same content. This may help.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

parth-vora-7 picture parth-vora-7  ·  4Comments

Patskimoto picture Patskimoto  ·  3Comments

Adesubomi picture Adesubomi  ·  4Comments

s4uron picture s4uron  ·  3Comments

duccanh0022 picture duccanh0022  ·  3Comments