I am working on a platform which connects with various eCommerse platforms to read all the products being sold on store and prepare a proprietary XML feed which is used to optimise Google Adwords.

The application started with Shopify e-commerce development and so we are using Shopify as OAuth provider. All good, the app is live and added lots of value to my clients.

Now I have to start adding more platform to the rails application and add authentication and authorization. Because the platform is built for Google AdWords and all the users would need Google+ account, we decided to use Google+ sign in for authentication.

We use Devise exclusively for all apps and so based on omniauth-google-oauth2 gem we implemented the Google Auth with Devise. Everything was looking good.

Now I have to refactor a bit to reuse some part of Shopify code. Refactoring done and I moved to test the Shopify App. On clicking theinstalled app it raised the following error.

No route matches [GET] "/auth/shopify" after introducing google omniauth

I stumbled around a bit and found a useful comment on the shopify_app issue list. I realised that the recent use of another omniauth provider(google in my case) has broken the app.

Here I will share how to make Shopify app working along with Devise and Omniauth. You basically have to follow non conventional devise path.

Let us undo what we had done while integration devise and google(or any oauth providers).

  1. Remove omniauthable module from User model.
  2. Move config.omniauth :google_oauth2, ... line from devise.rb to omniauth.rb
  3. Remove following controller configuration from devise_for in routes.rb

controllers: { omniauth_callbacks: 'users/omniauth_callbacks' }

4. Add new callback URL route to routes.rb

get '/auth/google_oauth2/callback' => 'users/omniauth_callbacks#google_oauth2'

5. Adjust the path helper that would go to Google for authentication

Here is full gist

Hope this saves you!

Click here for more details…

At BoTree Technologies, we build enterprise applications with our RoR team of 25+ engineers.

We also specialize in RPA, AI, Python, Django, JavaScript and ReactJS.

Consulting is free – let us help you grow!