Shopify - create a session for a private application

I am trying to create an application using RoR so that I can verify ShopifyAPI. I use a private application that I created through the portal of partner partners.

I tried to create a session using the generated password. The session seems valid.

login_controller:

def index debugger sess = ShopifyAPI::Session.new('a75999989b7715f73ae5273497b9bfcb: 9eb9f578d9fcfd753713e079@mante-hudson7934.myshopify.com ', '9eb9f578d9fcfd753713e0795') sess.valid? session[:shopify] = sess flash[:notice] = "Logged in" redirect_to return_address session[:return_to] = nil end 

But when I try to get all the products (products = ShopifyAPI :: Product.find (: all ,: params => {: limit => 10})

As a result, I get a 500 error.

here is the debug trace from me:

  1: ShopifyAPI::Base.site = https://a75999989b7715f73ae5273497b9bfcb: 9eb9f578d9fcfd753713e079596d4fbd@mante-hudson7934.myshopify.com /admin/ ~/.rvm/gems/ ruby-1.9.3-p194@rails328 /gems/shopify_app-4.0.0/lib/shopify_app/login_protection.rb:9 ShopifyAPI::Base.clear_session 

and in the browser I have an exception: "Connection reset by peer - SSL_connect"

Apparently the problem with my session ...

Is there something I am missing?

thanks

- EDIT -

Actually, I tried to capture products via IRB and as a result I got the same 500 Error: "Connection reset by peer - SSL_connect"

Not sure why I have this error?

Regis

+1
source share
2 answers

Most likely your client is trying to connect using TLS 1.2, one of the latest SSL / TLS protocols used in HTTPS. Our load balancing equipment has a known problem with TLS 1.2, although we did not know about it until I came across this error myself.

I told the rest of the Operations team about this, and I expect that we will fix this as soon as possible. Until then you can use

http.ssl_version = :TLSv1

to force Ruby to use TLS 1.0 instead. (Some clients may use :SSLv3 instead.)

Here is an example of how to apply this workaround to ActiveResource, a gem that uses shopify_api gem internally:

 require 'active_resource/connection' class ActiveResource::Connection def apply_ssl_options_with_ssl_version(http) apply_ssl_options_without_ssl_version(http) http.ssl_version = @ssl_options[:ssl_version] if @ssl_options && @ssl_options[:ssl_version] http end alias_method_chain :apply_ssl_options, :ssl_version end 

Now you can use

ShopifyAPI::Base.ssl_options = {:ssl_version => :TLSv1}

(or :SSLv3 , if necessary) to work around the problem.

+2
source

I am really under ubuntu environement. I just tried under the windows and seemed to work at least on the IRB console. As you mentioned, I may have problems with Ubuntu and OpenSSL. I will explore this leadership. thank you

------- EDIT ------- I tried to connect to the API under Mac OS X Lion, but got the same error. Does anyone have a hard time connecting to the Shopify API? If it is related to openssl, is there any way around this?

thanks

+1
source

Source: https://habr.com/ru/post/1434418/


All Articles