Update for 2.4.4
Since 2.4.4 version Magento has removed support of 'HMAC-SHA1' and all auth request should use the 'HMAC-SHA256'.
2.4.3 code:
/**
* Retrieve array of supported signature methods.
*
* @return string[] - Supported HMAC-SHA1 and HMAC-SHA256 signature methods.
*/
public static function getSupportedSignatureMethods()
{
return [self::SIGNATURE_SHA1, self::SIGNATURE_SHA256];
}
2.4.4 code:
/**
* Retrieve array of supported signature methods.
*
* @return string[]
*/
public static function getSupportedSignatureMethods()
{
return [self::SIGNATURE_SHA256];
}
Update:
Usually this error means you have a misprint in the request, like unnecessary space symbol somewhere :
rest/V1/carts/search?searchCriteria[filter_groups][0][filters][0] [field]=entity_id&searchCriteria[filter_groups][0][filters][0][value]=135&searchCriteria[filter_groups][0][filters][0][condition_type]=eq
In that example I've got it between the [filter_groups][0][filters][0]
and [field]=entity_id&
lines. Anyway I recommend you to rewrite your request one more time, letter-by-letter, to make sure everything is written correctly.
Original answer:
This error comes from the Magento\Framework\Oauth\Oauth
class and it means that calculated on the magento side signature IS NOT EQUAL to the signature from the authorization request. You can debug it in the method _validateSignature
(lines ~ 177-203). Here is the method:
/**
* Validate signature based on the signature method used.
*
* @param array $params
* @param string $consumerSecret
* @param string $httpMethod
* @param string $requestUrl
* @param string $tokenSecret
* @return void
* @throws Exception|OauthInputException
*/
protected function _validateSignature($params, $consumerSecret, $httpMethod, $requestUrl, $tokenSecret = null)
{
if (!in_array($params['oauth_signature_method'], self::getSupportedSignatureMethods())) {
throw new OauthInputException(
new Phrase(
'Signature method %1 is not supported',
[$params['oauth_signature_method']]
)
);
}
$allowedSignParams = $params;
unset($allowedSignParams['oauth_signature']);
$calculatedSign = $this->_httpUtility->sign(
$allowedSignParams,
$params['oauth_signature_method'],
$consumerSecret,
$tokenSecret,
$httpMethod,
$requestUrl
);
if (!Security::compareStrings($calculatedSign, $params['oauth_signature'])) {
throw new Exception(new Phrase('Invalid signature'));
}
}
The $params
comes here from the initial request and it stores an info like: tokens, signature, nonce etc.
First you should check your credentials on the another side: if you are using some kind of programs like Postman, may be it stored an old tokens. In this case just add a new info from the integration (tokens) and regenerate nonce.
If this does not help you, use xdebug and compare all params one by one, as it can be a typo in the one parameter.
PS: on the screenshot in left-bottom side you can see: what methods has been called in which order, may be it can help you.