2
votes

I am trying to test my Laravel php application with middleware using Postman. The application is using Tymon JWT Auth and according to the docs I should set the Authorization header:

Authorization: Bearer {yourtokenhere}

So, I've added the Authorization header to Postman like so:

enter image description here

But the response I get from my app is that token is not provided.

It's strange because:

  • If I attach the same token to url in Postman, the token is visible to the app (status 200 OK and no error saying token_not_provided).
  • If I test the app in PHPUnit instead of Postman and provide the token either in header or in url, it is also OK.
  • Debugging the raw Postman request in Fiddler shows that it actually has the Authorization header, as visible below:

enter image description here

I also tried deleting the other two headers from Postman but it didn't improve anything. So it seems that all is set up fine, but it's not working, why?

1

1 Answers

5
votes

Is your server on Apache? if yes,the following checklist will be helpful

  • You should configure your .htaccess properly inside public folder. Refer this

  • You should edit apache2.conf file

    sudo vi +164 /etc/apache2/apache2.conf And change to

    <Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
    

    • Then sudo a2enmod rewrite
    • Restart apache sudo service apache2 restart

This will work!