Select application login problem

I switched from authentication to oauth2 in the Shopify app. Now, when I visit the application on the store administration page (My Applications → Application), it always redirects me to the login page, and does not register the store directly in the application (as before).

Below is the code in the finalize method.

if response = request.env['omniauth.auth'] sess = ShopifyAPI::Session.new(params['shop'], response['credentials']['token']) ShopifyAPI::Base.activate_session(sess) session[:shopify] = sess flash[:notice] = "Logged in" redirect_to return_address session[:return_to] = nil else flash[:error] = "Could not log in to Shopify store." redirect_to :action => 'index' end 

When a user visits the application from the store administration page, he does not have request.env ['omniauth.auth'] in the request and is redirected to the login page, since this was not the case when we had an authentication mechanism.

The application URL is www.orderlyprint-staging.herokuapp.com. You can install the application in the test storage and try to enter the application from the administration page of the test store.

+4
source share
1 answer

For Shopify applications originally created using the gem of the Shopify App, and when switching from Legacy to oAuth2 authentication solution, you need to specify the Shopify Admin link for the authentication action instead of the finalization action. Therefore you need to:

Go to the Shopify Partner Administrator

Click "Edit Application Details"

Update the "Application URL" to indicate the authentication action. For example: www.orderlyprint-staging.herokuapp.com/login/authenticate

Then, the store parameter sent by Shopify will be retrieved and take the first oAuth authentication step, then redirect to the final action to complete. After that, the user will automatically log into the system without having to enter his store address manually.

+6
source

All Articles