shopify_app: Shopify Omniauth not getting the Request parameters

Using the Shopify App 8.1.0 gem to fire up a Rails 5.1.3 App and when trying to authenticate, it gets refused on a cryptic looking problem with an Invalid Site error. Anyone ever see this? What is usually the cause of that? Looking through OmniAuth Shopify strategy shows the request being processed is pretty much NIL… not sure why. No GET params and of course there is no valid site.

Seems to be connected to commit: b3dc3d9b67c8851526d492c8872b2b30503bf490

Started GET "/login?shop=swift-braun3430.myshopify.com" for 127.0.0.1 at 2017-09-06 08:38:48 -0400
Processing by ShopifyApp::SessionsController#new as HTML
Parameters: {"shop"=>"swift-braun3430.myshopify.com"}
Rendering inline template
Rendered inline template (0.3ms)
Completed 200 OK in 2ms (Views: 0.7ms | Models: 0.0ms)

Started GET "/auth/shopify" for 127.0.0.1 at 2017-09-06 08:38:48 -0400
I, [2017-09-06T08:53:19.504631 #78285]  INFO -- omniauth: (shopify) Set up endpoint detected, running now.
I, [2017-09-06T08:53:19.504727 #78285]  INFO -- omniauth: (shopify) Request phase initiated.
E, [2017-09-06T08:53:19.505025 #78285] ERROR -- omniauth: (shopify) Authentication failure! invalid_site encountered.
OmniAuth::Error (invalid_site):

omniauth (1.6.1) lib/omniauth/failure_endpoint.rb:25:in `raise_out!'
omniauth (1.6.1) lib/omniauth/failure_endpoint.rb:20:in `call'
omniauth (1.6.1) lib/omniauth/failure_endpoint.rb:12:in `call'
omniauth (1.6.1) lib/omniauth/strategy.rb:478:in `fail!'
omniauth-shopify-oauth2 (1.2.0) lib/omniauth/strategies/shopify.rb:105:in `request_phase'

A session dump shows:

locale: "en"
omniauth.origin: "https://sport-haley.dev/login?shop=swift-braun3430.myshopify.com"
omniauth.params: {}
return_to: "/"
session_id: "d9f7120cfa71f26b374162ee24798427"
shopify.omniauth_params: {"shop"=>"swift-braun3430.myshopify.com"}

So I hacked the Shopify App gem in the Sessions Controller, and under the authenticate method, I hacked on the shop parameter… so this is super cheesy and should not be happening right?

def authenticate
  if sanitized_shop_name.present?
    session['shopify.omniauth_params'] = { shop: sanitized_shop_name }

Here be dragons… the redirect does not contain the shop name unless I tack it on? PorKayWha?

    fullpage_redirect_to "#{main_app.root_path}auth/shopify?shop=#{sanitized_shop_name}"
  else
    redirect_to return_address
  end
end

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 17 (9 by maintainers)

Most upvoted comments

dude - this is a breaking change for anyone who types ‘bundle update’. There should be more visible notes than just on this ticket. Thanks for adding the note to the changelog – it helps. But for something like this, adding a note to the readme might be appropriate. That’s the first place I looked.

In general, when you release a breaking change for someone upgrading from older versions of the gem please take extra steps if you can to make sure our apps don’t stop working!

On the other side of this – overall it’s a really nice integration and the app itself is really helpful. Don’t want my complaining to overshadow that good work!

This was done in a major version bump because of those breaking changes… If you’re going to run a global bundle update you need to thoroughly test afterwards.

I suspect the example app is out of date. I’d recommend following the installation instructions here on a new rails app: https://github.com/Shopify/shopify_app#installation

I’m getting the same error I’m trying to run the example app, I follow all instructions showing here: https://github.com/Shopify/shopify_app/tree/master/example After I start Rails server I can access the app to enter my shop domain: http://prntscr.com/k2rg1z But when I click on “Install” it redirects me to another page and display the error: http://prntscr.com/k2rgvh

Can someone give me a solution for the issue?

Thanks

I took your Omniauth code that uses the session, and now the App works… lost a few hours dicking around till I stumbled into that… serves me right for not noticing the change from 8.0 to 8.1… subtle!