# Net:HTTP with authentification?

**URL:** <https://www.ruby-forum.com/t/net-http-with-authentification/174896>\
**Category:** Rails\
**Created:** [September 3, 2009, 5:23pm UTC](https://www.ruby-forum.com/t/net-http-with-authentification/174896 "2009-09-03T17:23:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![massi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b9e5f3/32.png) [@massi](https://www.ruby-forum.com/u/massi)\
**Post date:** [September 3, 2009, 5:23pm UTC](https://www.ruby-forum.com/t/net-http-with-authentification/174896/1 "2009-09-03T17:23:45Z")

</div>

hey ,

below an example of a code

url = URI.parse(‘[http://www.example.com/todo.cgi](http://www.example.com/todo.cgi)’)  
req = Net::HTTP:: Post.new(url.path)  
req.basic\_auth ‘jack’, ‘pass’  
req.set\_form\_data({‘from’=\>‘2005-01-01’, ‘to’=\>‘2005-03-31’}, ‘;’)  
res = Net::HTTP.new(url.host, url.port).start {|http| http.request(req)  
}

i use this code to get a component of a local page (different  
controller )

example : from home/index send a request to products/list

to send a request i need a password but i dont know how to get it ,  
how to decrypt it

is there another way to loggin without login and password , with session  
or cookies in the request header for exampe

thnx
