I have seen that this issue was mentioned in https://github.com/Shopify/shopify_app/issues/154, was merged but still open. I face the same issue with this gem on Rails 5.
My routes:
Rails.application.routes.draw do
root :to => 'home#index'
get '/dashboard' => 'dashboard#index', as: 'dashboard'
mount ShopifyApp::Engine, at: '/dashboard'
[...]
end
Now I log in from /dashboard/login. Once logged in, I get Oauth error invalid_request: The redirect_uri is missing or not whitelisted dispite I edited the app's Redirection URL in Shopify to https://www...../dashboard/auth/shopify/callback
Having the app mounted at root, I have no issues.
How to solve, please?
I would double check the redirect uri settings in the partner dashboard. Otherwise you'll have to see where you are being redirected and compare.
I'll update on this later. Thanks
@kevinhughes27 @SylarRuby I see the same, would you happen to have any updates on this?
Like you, the app redirects to the default /auth/shopify/callback
You might need to make some specific edits in the omniauth initializer that is generated for you. The omniauth readme might help. Please post back on this issue if you figure it out!
Correct. Same issue here. Used this Gem many times but this was the first I needed to namespace the front and backends.
@kevinhughes27 is right, mod the omniauth path and it will work. Just tried it.
Rails.application.config.middleware.use OmniAuth::Builder do
provider :shopify,
ShopifyApp.configuration.api_key,
ShopifyApp.configuration.secret,
scope: ShopifyApp.configuration.scope,
callback_path: '/dashboard/auth/shopify/callback'
end
FYI we need this for an internal project now and I am working on improving this in version 8.0.0. I am going to close this issue now though since this does work.
Apologies for the distant communication. When Im back on this task, I'll use latest version as I do not remember my last issue with this plugin. I guess I was a "basic junior" at that time 馃槑
馃憤 How to do this is going to be documented in the readme by the time you're back 馃樃
@kevinhughes27 How time flies? I'm back on the project with a bang. Any time frame for v8?
We haven't set a hard release date yet. There is a branch for development though and it is stable https://github.com/Shopify/shopify_app/pull/442. I am using it in production for a project already.
I have added a sub-directory. /myapp
But when I go to http://mysite.com/myapp, it redirects to http://mysite.com/login?return_to=%2Fmyapp%2F%3F, not http://mysite.com/myapp/login
That's why when installing an App, it redirects to
http://mysite.com/login?return_to=%2Fmyapp%2F%3Fhmac%3D5d81dbc6102603c6fc35931cba40f868614cf378f141ab151166d43868b4a97e%26shop%3Ddev.myshopify.com%26timestamp%3D1585300456&shop=dev-test1.myshopify.com
And I got Not Found: /login error.
routes.rb
Rails.application.routes.draw do
root :to => 'home#index'
get '/myapp' => 'myapp#index', as: 'myapp'
mount ShopifyApp::Engine, at: '/myapp'
end
ominiauth.rub
provider :shopify,
ShopifyApp.configuration.api_key,
ShopifyApp.configuration.secret,
scope: ShopifyApp.configuration.scope,
callback_path: '/myapp/auth/shopify/callback',
setup: lambda { |env|
strategy = env['omniauth.strategy']
shopify_auth_params = strategy.session['shopify.omniauth_params']&.with_indifferent_access
shop = if shopify_auth_params.present?
"https://#{shopify_auth_params[:shop]}"
else
''
end
strategy.options[:client_options][:site] = shop
strategy.options[:old_client_secret] = ShopifyApp.configuration.old_secret
strategy.options[:per_user_permissions] = strategy.session[:user_tokens]
}
end
Anyone had same issue?
Most helpful comment
Correct. Same issue here. Used this Gem many times but this was the first I needed to namespace the front and backends.
@kevinhughes27 is right, mod the omniauth path and it will work. Just tried it.