Saturday, 15 June 2013

Token authentication [Ruby on Rails] -



Token authentication [Ruby on Rails] -

simple code

require 'net/http' url = uri.parse('get json/other info here [link]') req = net::http::get.new(url.to_s) res = net::http.start(url.host, url.port) {|http| http.request(req) } puts res.body

just wondering how set authentication token in php curl

    curl_setopt($ch, curlopt_httpheader, array('authorization: bearer xxx')); //bearer token authentication

wondering how ruby

thanks!

you can add together header:

req = net::http::get.new(url.to_s) req['authorization'] = "bearer xxx"

or shorter:

request = net::http::get.new(url.to_s, {'authorization' => 'bearer vf9dft4qmt'})

ruby-on-rails ruby api rest

No comments:

Post a Comment