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
getting "Invalid Request! Request or redirect did not come from Shopify" error on install #22
Comments
What is the exact error you are receiving? Please post your log file for php errors if any relate to this. |
Hi @myjanky thanks a lot for the quick response, here I go ... the error I am getting in my browser after run the installation is: Invalid Request! Request or redirect did not come from Shopify with that clear I would like to make a review about the changes I've done with my conf.php and oauth.php in conf.php I just add a new line with my address is my callback address in my shopify backend : define('REDIRECT_URL', 'http://my-app-name.hosting.com/app/oauth.php'); once I did this, I move to make changes in my oauth.php with following changes: I place at the end of the line 16 my global variable "REDIRECT_URL" like this: $permission_url = shopify\authorization_url($_GET['shop'], SHOPIFY_APP_API_KEY, array('read_content', 'write_content', 'read_themes', 'write_themes', 'read_products', 'write_products', 'read_customers', 'write_customers', 'read_orders', 'write_orders', 'read_script_tags', 'write_script_tags', 'read_fulfillments', 'write_fulfillments', 'read_shipping', 'write_shipping'),REDIRECT_URL); after that I checked again my install URL but I get the same error in my browser after been redirected to the login to my shop and after log in I get this Invalid Request! Request or redirect did not come from Shopify then I move back to my oauth.php file and commented the line 11, this line Invalid Request! Request or redirect did not come from Shopify then I move back to my oauth.php file and commented the line 11, this line shopify\is_valid_request($_GET, SHOPIFY_APP_SHARED_SECRET) or die('Invalid Request! Request or redirect did not come from Shopify'); and after did this I tried again my install URL and get a different error: 400 - Oauth error invalid_request: The redirect_uri is missing or not came back to my oauth.php file and removed the comment in line 11, and finally I change the function for line 11 with the new one listed in the issue 19 changing function is_valid_request into this function is_valid_request_hmac($query_params, $shared_secret) { $hmac = $query_params['hmac']; foreach ($query_params as $key=>$val) $params[] = "$key=$val"; return (hash_hmac('sha256', implode('&', $params), $shared_secret) === $hmac); but then I get again this error 400 - Oauth error invalid_request: The redirect_uri is missing or not so what can I do next ? |
Your redirect URL must match that in your partner's account app dashboard @ developers.shopify.com The error is unrelated to is_valid_request_hmac. What is your partners dashboard app redirect url. (callback) |
my callback http://myapp.hekities.com/app/oauth.php and is the one I defined in conf.php and my oauth.php in the line 11 like this shopify\is_valid_request($_GET, SHOPIFY_APP_SHARED_SECRET) or die('Invalid Request! Request or redirect did not come from Shopify'); |
Hmmm. Can you host with SSL? I had many issues until I SSL my app domain. |
hummm I need to check my hosting, I don't think so but let me try |
heroku has ssl containers you can move the code to. On Fri, Jul 29, 2016 at 10:37 AM, alexandprivate notifications@github.com
Larry Wheeler "I believe that the money is in making the tools. They say during the gold [image: Inline image 1] http://www.sleepingbaby.com/ |
Can you post the entire oauth.php file you have? |
good idea. let me try my hosting and keep you posted about the SSL... |
top.location.href='$permission_url '</script>"); } # Step 3: http://docs.shopify.com/api/authentication/oauth#confirming-installation try { # shopify\access_token can throw an exception $oauth_token = shopify\access_token($_GET['shop'], SHOPIFY_APP_API_KEY, SHOPIFY_APP_SHARED_SECRET, $_GET['code']); $_SESSION['oauth_token'] = $oauth_token; $_SESSION['shop'] = $_GET['shop']; echo 'App Successfully Installed!'; } catch (shopify\ApiException $e) { # HTTP status code was >= 400 or response contained the key 'errors' echo $e; print_R($e->getRequest()); print_R($e->getResponse()); } catch (shopify\CurlException $e) { # cURL error echo $e; print_R($e->getRequest()); print_R($e->getResponse()); } ``` ?> |
Ok I see some issues. With composer it is getting shopify.php from phpish library.
I think you may be getting hung up on step one, prior to asking for permission. what does it contain? |
Also, is the redirect url visible in the URI as a query param (get var.) |
yeah but I change the function in shopify.php so it is working fine and doing the check by hmac ... notice if not the error will go with die and thats not the problem the function is working fine I am getting the error in line 16 |
LARRY ! the app have been installed !!! dont ask me how or why !!! kinda budu or something ! I change nothing ! |
I think it was a cache problem or something !!! thanks a lot pal !!!! write you back about further issues and success ! thanks again |
Are you not using composer to get your libraries? Changing shopify.php will only work if you disable composer. Yes, could be a cache issue due to composer. |
no worries. Hope you get the app together how you want. |
yeah ! I think it was that ! |
thanks man |
Hi, still stuck at this error! (Invalid Request! Request or redirect did not come from Shopify) Any help? Totally new to shopify |
see if the shared secret is getting passed into the is_valid_request() properly. |
Problem was 'signature index'. now instead of signature, 'hmac' is being used. Thanks :) |
Hi The patch is not working. Please give me the url for the updated patch. I am also facing the same issue. |
@sanishkamboj
this is from ohShopify. I take no credit for the function |
Hello, I am having this persistent error every time I try to install my app and this is so far the many things I have tried.
I have phpish/shopify_app-skeleton in my server and compose install with all dependencies
after that I change my conf.php adding a global variable for redirecting URL:= like this
define('REDIRECT_URL', 'http://my-app-name.hosting.com/app/oauth.php');
after that in my oauth.php file I place at the end of the line 16 my gobal variable "REDIRECT_URL" like this:
$permission_url = shopify\authorization_url($_GET['shop'], SHOPIFY_APP_API_KEY, array('read_content', 'write_content', 'read_themes', 'write_themes', 'read_products', 'write_products', 'read_customers', 'write_customers', 'read_orders', 'write_orders', 'read_script_tags', 'write_script_tags', 'read_fulfillments', 'write_fulfillments', 'read_shipping', 'write_shipping'),REDIRECT_URL);
also I have commented the line 11:
shopify\is_valid_request($_GET, SHOPIFY_APP_SHARED_SECRET) or die('Invalid Request! Request or redirect did not come from Shopify');
even I have replace line 11 with the function explained in this post but not result came up.
but nothing works... any advice ??? anything else to do, I am doing something wrong o missing any steps?
The text was updated successfully, but these errors were encountered: