Dominik
Dominik

Reputation: 299

Passport Error "Unauthenticated"

I´m using Laravel 5.5 & newest passport.

I try to secure my api via passport and implemented it with the offical laravel docu.

First I receive a Bearer-Token with an api-call to .../auth/token. Then I try to make this get-request via postman: HEAD:

X-CSRF-TOKEN: zkmOKxFxGSG75QdZjuhHJkwUJ18FkHWm3OUxzZ8j
X-Requested-With: XMLHttpRequest
Accept: application/json
Authorization: Bearer bearer-token

And I always get the following answer: Status: 401: Unauthorized

{
    "error": "Unauthenticated."
}

I don´t know how to handle this. In my .htaccess:

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>

Edit: I upgraded Laravel to v. 5.5

Upvotes: 1

Views: 869

Answers (1)

Dominik
Dominik

Reputation: 299

Okay I found my problem. For token generation I used grant-type "password". With client_credentials it works now.

Upvotes: 1

Related Questions