1
votes

Looking for the convenience of Auth0 to sort out JWTs between my Angular 2 client and Laravel 5.3 API. I've followed (and double-checked that I've followed) Auth0's getting started guide:

https://auth0.com/docs/quickstart/backend/php-laravel

But can't seem to get it to authenticate me. When I curl as follows:

curl --request GET --url http://localhost/api/test --header 'authorization: auth0_id_token'

I get:

Unauthorized user curl: (6) Could not resolve host: auth0_id_token

In my \routes\api, I have:

Route::get('/test', array('middleware' => 'auth0.jwt', function() {
    return "Hello " . Auth0::jwtuser()->name;
}));

I'm generating the id_token using this:

https://auth0.com/docs/api/authentication#!#post--oauth-ro

and can see when I go to (https://manage.auth0.com/#/users) that Auth0 thinks the user has logged in.

Any pointers for where I should be looking to try and debug this?

1

1 Answers

1
votes

The correct way to include a bearer token in the HTTP Authorization header is to use the Bearer authentication scheme, so your header should be:

Authorization: Bearer [auth0_id_token]

Additionally, the error you received from curl also indicates that the command is not being parsed as you intended, more specifically, it seems 'authorization: auth0_id_token' is being parsed as multiple arguments which results in the auth0_id_token part being considered as an URL which will fail when trying to resolve the host; try to use double quotes instead.