Api: Authentication with jwt

Created on 14 Oct 2016  路  8Comments  路  Source: dingo/api

Hi all,

i have latest version of laravel with jwt package.
I read this guide to implement jwt on laravel 5.3.

In config/api.php i set dingo jwt provider :

'auth' => [
        'jwt' => 'Dingo\Api\Auth\Provider\JWT',
],

Login function work correctly but when i try to access the protected route (with $this->middleware('api.auth') on construct on my controller) dingo response me with 401 code.

I don't know why this error occurs.

Where am I doing wrong?

Thanks

Most helpful comment

Hello,

Can you share your code how you are creating the login for jwt?

All 8 comments

401 means unauthorized. Are you passing the token with your request

Try adding your middleware in your route, not on your Controllers constructor.

Also how do you pass your token to your request?

Hi all, thanks for your reply.

Are you passing the token with your request ?

Of course i added token on query token={tokenString} and on header Authorization with value Bearer {tokenString}

Try adding your middleware in your route, not on your Controllers constructor.

I tried but same results.

Thanks

Any errors on logs?

Nothing ...

Hi all,

i try to reinstall and reconfigure all.
Now it's works!
I looked for the differences, but I found nothing.

Anyway thanks for your support.

Interested on how to finx this

Hello,

Can you share your code how you are creating the login for jwt?

Was this page helpful?
0 / 5 - 0 ratings