Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid Request! Request or redirect did not come from Shopify #45

Open
pkp2409 opened this issue Mar 2, 2018 · 7 comments
Open

Invalid Request! Request or redirect did not come from Shopify #45

pkp2409 opened this issue Mar 2, 2018 · 7 comments

Comments

@pkp2409
Copy link

pkp2409 commented Mar 2, 2018

Hi,
I'm converted the local server into https using "ngrok" method, still I'm facing the issue "Invalid Request! Request or redirect did not come from Shopify"
desktop screenshot

Can you please to create the sample application using php in shopify

Thank you,

@tareq0065
Copy link

I m getting too

@ann1111
Copy link

ann1111 commented Jan 26, 2019

Any updates in it ?

@VickyFi
Copy link

VickyFi commented Feb 27, 2019

Did you find anything on that? I' m getting the same error too.

@sunboy88
Copy link

sunboy88 commented Mar 1, 2019

Guys, skip oauth.php file, only need install.php to installed...

@ahmu83
Copy link

ahmu83 commented Mar 13, 2019

I am getting this error when I try to install the shopify app Notice: Undefined index: signature in /vendor/phpish/shopify/shopify.php on line 21
Invalid Request! Request or redirect did not come from Shopify

I noticed that the url https://ID.ngrok.io/oauth.php?hmac=&shop=MY-TEST-STORE.myshopify.com&timestamp=1552491745 did not have the signature query string instead of the hmac query string. And I tried to update that instead in line 21 but it only removed the notice but the error (Invalid Request! Request or redirect did not come from Shopify) was still there

@X4nd0R
Copy link

X4nd0R commented Aug 9, 2020

The fix is not to skip oauth.php and go straight to install.php. When I did this I got stuck in an infinite loop. This issue is actually a duplicate and I posted the fix in there but just to make sure anyone who needs it finds this, I was able to solve this issue by editing the phpish file: /vendor/phpish/shopify/shopify.php. The is_valid_request() function should look like this:

function is_valid_request($query_params, $shared_secret)
{
	if (!isset($query_params['timestamp'])) return false;

	$seconds_in_a_day = 24 * 60 * 60;

	$older_than_a_day = $query_params['timestamp'] < (time() - $seconds_in_a_day);
	if ($older_than_a_day) return false;

	$signature = $query_params['hmac'];
	unset($query_params['hmac']);

	$message = http_build_query($query_params);

	return (hash_hmac('sha256', $message, $shared_secret) === $signature);
}

I believe the Shopify API/Oauth system has changed and phpish's code is out of date.

@X4nd0R
Copy link

X4nd0R commented Aug 13, 2020

After getting this working I still continued to have issues with this project (such as app not embedding, plus other issues). I ended up writing a fresh bare-bones app that is plug and play for Shopify. If anyone else is still having issues getting this working, please check mine out here: https://github.com/XenithTech/php-shopify-app-skeleton If you have any issues with it feel free to open a ticket and I will actively work on a solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants