Wrong redirect URI using shopify-app gem

543 views Asked by At

I've been trying to create an application these past few days. First I've been trying to create an app on localhost (http://localhost) but have been getting errors since Shopify is only supporting https. Then I deployed the application to my VPS (https://my.domain.com) and have specified the callback-URL in my partners account as well (https://my.domain.com). When I enter the shop where I want to install my application the installation window pops up and I can click on "Install". If I do so, the same mismatch occurs. I figured out it was because the URL looks like this:

https://shop.myshopify.com/admin/oauth/authorize?client_id=XXX&redirect_uri=HTTP%3A%2F%2Flocalhost%3...

This is where the mismatch happens. I do not understand why because the redirect_uri should be the callback-URL by default, if not specified otherwise. The callback-app-URL is "https://my.domain.com" so why is the redirect_uri "http://..." and how can I fix this?

I suppose I need to specify the redirect_uri somewhere in my omniauth.rb initializer?

provider :shopify, redirect_uri: "https://localhost:3000"

ShopifyApp.configuration.api_key,
ShopifyApp.configuration.secret,

:scope => ShopifyApp.configuration.scope,

:setup => lambda {|env|
   params = Rack::Utils.parse_query(env['QUERY_STRING'])
   site_url = "https://#{params['shop']}"
   env['omniauth.strategy'].options[:client_options][:site] = site_url
}

Any help is appreciated, really don't know what to do

0

There are 0 answers