2

I need to generate access token for third party extension in Magento. I create integration, now I should sent request to /oauth/token/request in order to get a request token, but I get following error:

oauth_problem=The+signatire+is+invalid.+Verify+and+try+again.

My signature function is as follow

function sign($method, $url, $data, $consumerSecret, $tokenSecret)
{
 $array=[
 $method,
 $url,
 $data['oauth_nonce'],
 $data['oauth_signature_method'],
 $data['oauth_timestamp'],
 $data['oauth_version'],
 $data['oauth_consumer_key'],
 $tokenSecret,
 ];
 $url = urlEncodeAsZend($url);
 $data = urlEncodeAsZend(http_build_query($array, '', '&'));
 $data = implode('&', $array);
 $secret = implode('&', [$consumerSecret, $tokenSecret]);
 return base64_encode(hash_hmac('sha1', $data, $secret, true));
}
function urlEncodeAsZend($value)
{
 $encoded = rawurlencode($value);
 $encoded = str_replace('%7E', '~', $encoded);
 return $encoded;
}

PS: my oauth_token is empty because in this step no token is created in Integrations.Doc says :

To generate the signature, you must use the HMAC-SHA1 signature method. The signing key is the concatenated values of the consumer secret and token secret separated by the ampersand (&) character (ASCII code 38), even if empty.

https://devdocs.magento.com/guides/v2.2/get-started/authentication/gs-authentication-oauth.html

I am using Magento 2.3

asked Nov 10, 2018 at 20:24

1 Answer 1

0
answered Nov 21, 2018 at 10:55

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.