Attempting to connect to the Digest Authentication web service using HTTParty or Net: HTTP (or etc.)

I am trying to connect to a web service using digest authentication.

I can connect to Safari using user: password@service.site.com / endpoint

I tried using Ruby and Rails to connect using HTTParty and Net: HTTP using the "basic" auth options, but no luck.

Want to know if the HTTParty / Net: HTTP "basic_auth" parameter is compatible with the digest auth service?

If not, is there any other way to connect?

+3
source share
2

HTTParty basic auth, -, digest_auth. Net: HTTP: https://codesnippets.joyent.com/posts/show/1075, , Crack http://github.com/jnunemaker/crack:

 def self.decode vin
    url = URI.parse(APP_CONFIG[:vinlink_url])
    Net::HTTP.start(url.host) do |http|
      res = http.head(url.request_uri)
      req = Net::HTTP::Get.new("/report?type=basic&vin=#{vin}")
      req.digest_auth(APP_CONFIG[:vinlink_login], APP_CONFIG[:vinlink_password], res)
      @response = http.request(req)
    end
    if @response.code == "200"
      hash = Crack::XML.parse(@response.body).recursive_downcase_keys!.recursive_symbolize_keys!
    end
  end  
+2

, https://gist.github.com/73102. , , "Stale client nonce" - nonce digest_auth , . , , , - .

0

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


All Articles