I have an app on Shopify marketplace.
Once a client installs my app on is Shopify account - I save the store access_token in order to create API CALL later.
The problem is, The client uninstalls my app, and then install the app again. But the is store aceess_token remains the same (I not producing new access_token during the second install. because the client already exist on my database.
How can I generate a new Shopify store access token through Shopify API CALL?
function getAccessToken($shop, $apiKey, $secret, $code) {
$query = array(
'client_id' => $apiKey,
'client_secret' => $secret,
'code' => $code
);
// Build access token URL
$access_token_url = "https://{$shop}/admin/oauth/access_token";
// Configure curl client and execute request
$curl = curl_init();
$curlOptions = array(
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_URL => $access_token_url,
CURLOPT_POSTFIELDS => http_build_query($query)
);
curl_setopt_array($curl, $curlOptions);
$jsonResponse = json_decode(curl_exec($curl), TRUE);
curl_close($curl);
return $jsonResponse['access_token'];
}