在文档中创建 HTTP 请求时我需要进行身份验证
$httpClient = HttpClient::create([
'auth_basic' => ['user@gmail.com', '45@8888'],
]);
$httpClient = HttpClient::create([
// HTTP Basic authentication with only the username and not a password
'auth_basic' => ['the-username'],
// HTTP Basic authentication with a username and a password
'auth_basic' => ['the-username', 'the-password'],
// HTTP Bearer authentication (also called token authentication)
'auth_bearer' => 'the-bearer-token',
]);
所以写的时候
$response = $httpClient->request('GET', 'https://...', [
// use a different HTTP Basic authentication only for this request
'auth_basic' => ['the-username', 'the-password'],
// ...
]);
抛出异常
Symfony\Component\HttpClient\Exception\ClientException: HTTP/1.1 400 Bad Request 返回“ http://site.test/login_check ”。
是否因为我没有发布字段 user[_token] 而抛出异常?如果是,如何生成它并添加到请求中?如果有人已经使用此组件登录,请给我代码:)