Guzzle 无法通过 shopware5 进行身份验证
Guzzle fails to authenticate with shopware5
我正在尝试将查询 shopware5 API 的以下工作 HTTP_Request2 代码移植到 Guzzle 7
$request = new \HTTP_Request2();
$request->setBody('{"limit": 500000}');
$request->setUrl($URL.'/customers');
$request->setMethod(\HTTP_Request2::METHOD_GET);
$request->setHeader('Accept-Encoding','gzip, deflate, br');
$request->setAuth($username, $apiKey, \HTTP_Request2::AUTH_DIGEST);
$response = $request->send();
我尝试了以下方法,但失败并显示消息“无效或缺少授权”
$RESTClient = new Client();
$request = new Guzzle_request(
'GET',
$URL .'/customers',
[
'body' => '{"limit": 500000}',
'decode_content' => 'gzip, deflate, br',
'auth' => [$username, $apiKey, 'digest']
]);
$response = $RESTClient->send($request);
您需要更改密码
use GuzzleHttp\Psr7\Request;
$client = new GuzzleHttp\Client();
$headers = ['Accept-Encoding' => 'gzip, deflate, br'];
$body = '{"limit": 500000}';
$request = new Request('GET', $URL . '/customers', $headers, $body);
$response = $client->send($request, [
'verify' => false,
'auth' => [$username, $apiKey, 'digest']
]);
由于 Digest 有 md5,所以 verify as false 不会使它不安全,但我没有在任何地方找到它的原因,但看到 digest 只适用于 verify as false。
你也可以继续使用 decode_content
没问题,虽然默认情况下它是真的所以如果我通过 header 那么我想没有问题。
我正在尝试将查询 shopware5 API 的以下工作 HTTP_Request2 代码移植到 Guzzle 7
$request = new \HTTP_Request2();
$request->setBody('{"limit": 500000}');
$request->setUrl($URL.'/customers');
$request->setMethod(\HTTP_Request2::METHOD_GET);
$request->setHeader('Accept-Encoding','gzip, deflate, br');
$request->setAuth($username, $apiKey, \HTTP_Request2::AUTH_DIGEST);
$response = $request->send();
我尝试了以下方法,但失败并显示消息“无效或缺少授权”
$RESTClient = new Client();
$request = new Guzzle_request(
'GET',
$URL .'/customers',
[
'body' => '{"limit": 500000}',
'decode_content' => 'gzip, deflate, br',
'auth' => [$username, $apiKey, 'digest']
]);
$response = $RESTClient->send($request);
您需要更改密码
use GuzzleHttp\Psr7\Request;
$client = new GuzzleHttp\Client();
$headers = ['Accept-Encoding' => 'gzip, deflate, br'];
$body = '{"limit": 500000}';
$request = new Request('GET', $URL . '/customers', $headers, $body);
$response = $client->send($request, [
'verify' => false,
'auth' => [$username, $apiKey, 'digest']
]);
由于 Digest 有 md5,所以 verify as false 不会使它不安全,但我没有在任何地方找到它的原因,但看到 digest 只适用于 verify as false。
你也可以继续使用 decode_content
没问题,虽然默认情况下它是真的所以如果我通过 header 那么我想没有问题。