Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is solution:</p> <p>I used token_authenticatable from devise. </p> <p><a href="https://stackoverflow.com/questions/4627703/using-devise-tokens-to-log-in-is-this-built-in/4670812#4670812">Here</a> is one great answer how to implement it with json. I had some trouble and described them <a href="https://stackoverflow.com/questions/6912542/routingerror-uninitialized-constatnt">in this question</a>. There is also answer. </p> <p>Here goes example code: </p> <pre><code>require "net/http" require "json" @host = "localhost" @port = 3000 @post_sign = "/users/sign_in.json" @post_ws = "/external/rd" @req_sign = { "user" =&gt; { "email" =&gt; "some@email.com", "password" =&gt; "123456" } }.to_json sig = Net::HTTP::Post.new(@post_sign, initheader = {'Content-Type' =&gt; 'application/json'}) sig.body = @req_sign http = Net::HTTP.new(@host, @port).start resp1 = http.request(sig) puts "Response: #{resp1.code} , Message: #{resp1.message} , Body: #{resp1.body}" if resp1.code == "200" then puts "logged in" json_resp = JSON.parse(resp1.body) @auth_token = json_resp['auth_token'] @req_body = { "device" =&gt; { "name" =&gt; "device_json", "operating_system_id" =&gt; "7", "hash_string" =&gt; "jfsg3k4ovj0j02jv" }, "auth_token" =&gt; @auth_token }.to_json req = Net::HTTP::Post.new(@post_ws, initheader = {'Content-Type' =&gt;'application/json'}) req.body = @req_body response = http.request(req) puts "Response: #{response.code} , Message: #{response.message} , Body: #{response.body}" end </code></pre> <p>Regards, Mateusz</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload