从 curl 使用 Auth0 调用 Laravel 5.3 API 时未经授权的用户

Unauthorized user when calling Laravel 5.3 API with Auth0 from curl

寻找方便的 Auth0 来整理我的 Angular 2 客户端和 Laravel 5.3 API 之间的 JWT。我已经关注(并仔细检查我是否已经关注)Auth0 的入门指南:

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

但似乎无法通过它来验证我的身份。当我卷曲如下时:

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

我得到:

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

在我的 \routes\api 中,我有:

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

我正在使用此生成 id_token

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

当我转到 (https://manage.auth0.com/#/users) 时可以看到 Auth0 认为用户已登录。

关于我应该在哪里尝试调试它的任何指示?

在 HTTP Authorization header 中包含承载令牌的正确方法是使用 Bearer 身份验证方案,因此您的 header 应该是:

Authorization: Bearer [auth0_id_token]

此外,您从 curl 收到的错误还表明该命令没有按照您的预期进行解析,更具体地说,似乎 'authorization: auth0_id_token' 被解析为多个参数,这导致auth0_id_token 部分被视为 URL,在尝试解析主机时会失败;尝试改用双引号。