I have rewrite rule in .htaccess
# Sets the HTTP_AUTHORIZATION header removed by Apache
RewriteCond %{HTTP:Authorization} .
RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
trying to test sending a jwt authorization
$res = $this->client->request('GET',
'http://localhost/api/private', [
'headers' => [
'Authorization' => 'Bearer JWTTOKEN'
]
]);
http://localhost/api/private resulted in a 401 Unauthorized response:\\n{\\"code\\":401,\\"message\\":\\"JWT Token not found
You are sending a GET
and should probably be sending POST
$res = $this->client->request('POST',
'http://localhost/api/private', [
'headers' => [
'Authorization' => 'Bearer JWTTOKEN'
]
]);
在清除产品缓存并在此处仔细检查我的虚拟主机文件设置之后, https://symfony.com/doc/current/setup/file_permissions.html我开始得到一个空响应,问题是我得到了一个空响应我使用的不是正确的口吃,我必须从响应主体获取响应并对其进行解码
return new JsonResponse(json_decode($res->getBody()->getContents()));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.