Hello, i am folowing this tutorial: Shopify App Development: How To Create Shopify Apps Locally - YouTube
my app installs fine, hmac is verified ,the problem is when requesting the store access token.
here is my code for the token.php file
'')); // Remove hmac from params
ksort($params); // Sort params lexographically
$computed_hmac = hash_hmac('sha256', http_build_query($params), $shared_secret);
// Use hmac data to check that the response is from Shopify or not
if (hash_equals($hmac, $computed_hmac)) {
// Set variables for our request
$query = array(
"client_id" => $api_key, // Your API key
"client_secret" => $shared_secret, // Your app credentials (secret key)
"code" => $params['code'] // Grab the access key from the URL
);
// Generate access token URL
$access_token_url = "https://" . $params['shop'] . "/admin/oauth/access_token";
// Configure curl client and execute request
$ch = curl_init();
echo var_dump($ch);
echo var_dump($access_token_url);
echo var_dump($query);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $access_token_url);
curl_setopt($ch, CURLOPT_POST, count($query));
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($query));
echo var_dump(http_build_query($query));
$result = curl_exec($ch);
curl_close($ch);
echo var_dump($result);
// Store the access token
$result = json_decode($result, true);
$access_token = $result['access_token'];
echo var_dump($result);
// Show the access token (don't do this in production!)
echo var_dump($access_token);
echo "# testing heeyyy macarena" . $access_token;
} else {
// Someone is trying to be shady!
die('This request is NOT from Shopify!');
}
and here what this outputs:
Thank you!
