Change authorization in request header


Anthony Roux <m.roux.a@...>
 

Hello,

I'm using rest-client to manage lot's of my applications. Since now they didn't had any sort of authentication. I just finished to deploy it, so i need to be able to interact (though an API) between my applications despite they need to be authenticate. The problem is i can't find a way to put my authorization on the headers on a get :

I would like to be able to do something like that : 

@response = RestClient.get "my_url", :accept => @accept, :content_type => @content_type, :authorization => @authorization 

But i always have an error 500...

Sincerely, 
Anthony Roux.


Manuel Palenciano <mpalenciano@...>
 

Hello Anthony,

I think you put that in the URL

'user:passwd@your_url'

Manuel

On Jul 27, 2011, at 4:36 PM, Anthony Roux wrote:

Hello,

I'm using rest-client to manage lot's of my applications. Since now they didn't had any sort of authentication. I just finished to deploy it, so i need to be able to interact (though an API) between my applications despite they need to be authenticate. The problem is i can't find a way to put my authorization on the headers on a get :

I would like to be able to do something like that : 

@response = RestClient.get "my_url", :accept => @accept, :content_type => @content_type, :authorization => @authorization 

But i always have an error 500...

Sincerely, 
Anthony Roux.



Anthony Roux <m.roux.a@...>
 

Hello Manuel, thanks for your answer,

I don't have the user and password. I mean i can get it but I prefer work with the token that i already have. I just need a way to put my authorization to the header.

Anthony.

2011/7/27 Manuel Palenciano <mpalenciano@...>

Hello Anthony,

I think you put that in the URL

'user:passwd@your_url'

Manuel

On Jul 27, 2011, at 4:36 PM, Anthony Roux wrote:

Hello,

I'm using rest-client to manage lot's of my applications. Since now they didn't had any sort of authentication. I just finished to deploy it, so i need to be able to interact (though an API) between my applications despite they need to be authenticate. The problem is i can't find a way to put my authorization on the headers on a get :

I would like to be able to do something like that : 

@response = RestClient.get "my_url", :accept => @accept, :content_type => @content_type, :authorization => @authorization 

But i always have an error 500...

Sincerely, 
Anthony Roux.




Archiloque <code@...>
 

Normally RestClient.get "my_url", :accept => @accept, :content_type => @content_type, :authorization => @authorization should work as expected, could you activate the log (RestClient.log = 'stdout') and send me the resulting request ?

A.

Le 27 juil. 2011 à 16:46, Anthony Roux a écrit :

Hello Manuel, thanks for your answer,

I don't have the user and password. I mean i can get it but I prefer work with the token that i already have. I just need a way to put my authorization to the header.

Anthony.

2011/7/27 Manuel Palenciano <mpalenciano@...>
Hello Anthony,

I think you put that in the URL

'user:passwd@your_url'

Manuel

On Jul 27, 2011, at 4:36 PM, Anthony Roux wrote:

Hello,

I'm using rest-client to manage lot's of my applications. Since now they didn't had any sort of authentication. I just finished to deploy it, so i need to be able to interact (though an API) between my applications despite they need to be authenticate. The problem is i can't find a way to put my authorization on the headers on a get :

I would like to be able to do something like that : 

@response = RestClient.get "my_url", :accept => @accept, :content_type => @content_type, :authorization => @authorization 

But i always have an error 500...

Sincerely, 
Anthony Roux.





Anthony Roux <m.roux.a@...>
 

Hello,


RestClient.get "http://55.7.28.210:4321/TSI-Dev/", "Accept"=>"text/plain", "Accept-Encoding"=>"gzip, deflate", "Authorization"=>"Basic YW50aG9ueTphbnRob255", "Content-Type"=>"text/plain"
# => 500 InternalServerError | text/html 847 bytes

Anthony.

2011/7/27 Archiloque <code@...>

Normally RestClient.get "my_url", :accept => @accept, :content_type => @content_type, :authorization => @authorization should work as expected, could you activate the log (RestClient.log = 'stdout') and send me the resulting request ?

A.

Le 27 juil. 2011 à 16:46, Anthony Roux a écrit :

Hello Manuel, thanks for your answer,

I don't have the user and password. I mean i can get it but I prefer work with the token that i already have. I just need a way to put my authorization to the header.

Anthony.

2011/7/27 Manuel Palenciano <mpalenciano@...>
Hello Anthony,

I think you put that in the URL

'user:passwd@your_url'

Manuel

On Jul 27, 2011, at 4:36 PM, Anthony Roux wrote:

Hello,

I'm using rest-client to manage lot's of my applications. Since now they didn't had any sort of authentication. I just finished to deploy it, so i need to be able to interact (though an API) between my applications despite they need to be authenticate. The problem is i can't find a way to put my authorization on the headers on a get :

I would like to be able to do something like that : 

@response = RestClient.get "my_url", :accept => @accept, :content_type => @content_type, :authorization => @authorization 

But i always have an error 500...

Sincerely, 
Anthony Roux.






Anthony Roux <m.roux.a@...>
 

If I use this method : 

def get_response_with_auth(url)
      url_parsed = URI.parse(url) 
      
      @response = Net::HTTP.start(url_parsed.host, url_parsed.port) {|http| 
            req = http.get('/', {'Authorization' => @authorization, 'Accept' => @accept }) 
      }
  end

I don't have any problem. What can be the difference between them ?

Anthony.

2011/7/28 Archiloque <code@...>

The authorization is in the header so you'll have to be sure the value is ok and perhaps check with the service provider

A.




Le 28 juil. 2011 à 10:19, Anthony Roux <m.roux.a@...> a écrit :

Hello,


RestClient.get "http://55.7.28.210:4321/TSI-Dev/", "Accept"=>"text/plain", "Accept-Encoding"=>"gzip, deflate", "Authorization"=>"Basic YW50aG9ueTphbnRob255", "Content-Type"=>"text/plain"
# => 500 InternalServerError | text/html 847 bytes

Anthony.

2011/7/27 Archiloque <code@...>
Normally RestClient.get "my_url", :accept => @accept, :content_type => @content_type, :authorization => @authorization should work as expected, could you activate the log (RestClient.log = 'stdout') and send me the resulting request ?

A.

Le 27 juil. 2011 à 16:46, Anthony Roux a écrit :

Hello Manuel, thanks for your answer,

I don't have the user and password. I mean i can get it but I prefer work with the token that i already have. I just need a way to put my authorization to the header.

Anthony.

2011/7/27 Manuel Palenciano <mpalenciano@...>
Hello Anthony,

I think you put that in the URL

'user:passwd@your_url'

Manuel

On Jul 27, 2011, at 4:36 PM, Anthony Roux wrote:

Hello,

I'm using rest-client to manage lot's of my applications. Since now they didn't had any sort of authentication. I just finished to deploy it, so i need to be able to interact (though an API) between my applications despite they need to be authenticate. The problem is i can't find a way to put my authorization on the headers on a get :

I would like to be able to do something like that : 

@response = RestClient.get "my_url", :accept => @accept, :content_type => @content_type, :authorization => @authorization 

But i always have an error 500...

Sincerely, 
Anthony Roux.







Archiloque <code@...>
 

The authorization is in the header so you'll have to be sure the value is ok and perhaps check with the service provider

A.




Le 28 juil. 2011 à 10:19, Anthony Roux <m.roux.a@...> a écrit :

Hello,


RestClient.get "http://55.7.28.210:4321/TSI-Dev/", "Accept"=>"text/plain", "Accept-Encoding"=>"gzip, deflate", "Authorization"=>"Basic YW50aG9ueTphbnRob255", "Content-Type"=>"text/plain"
# => 500 InternalServerError | text/html 847 bytes

Anthony.

2011/7/27 Archiloque <code@...>
Normally RestClient.get "my_url", :accept => @accept, :content_type => @content_type, :authorization => @authorization should work as expected, could you activate the log (RestClient.log = 'stdout') and send me the resulting request ?

A.

Le 27 juil. 2011 à 16:46, Anthony Roux a écrit :

Hello Manuel, thanks for your answer,

I don't have the user and password. I mean i can get it but I prefer work with the token that i already have. I just need a way to put my authorization to the header.

Anthony.

2011/7/27 Manuel Palenciano <mpalenciano@...>
Hello Anthony,

I think you put that in the URL

'user:passwd@your_url'

Manuel

On Jul 27, 2011, at 4:36 PM, Anthony Roux wrote:

Hello,

I'm using rest-client to manage lot's of my applications. Since now they didn't had any sort of authentication. I just finished to deploy it, so i need to be able to interact (though an API) between my applications despite they need to be authenticate. The problem is i can't find a way to put my authorization on the headers on a get :

I would like to be able to do something like that : 

@response = RestClient.get "my_url", :accept => @accept, :content_type => @content_type, :authorization => @authorization 

But i always have an error 500...

Sincerely, 
Anthony Roux.






Archiloque <code@...>
 

Is authorization a String ? It may be the way it transform it into a String

You could try starting a simple local rack app that logs your requests' headers and execute both resquests against it and check if you see any difference ?

A.




Le 28 juil. 2011 à 10:35, Anthony Roux <m.roux.a@...> a écrit :

If I use this method : 

def get_response_with_auth(url)
      url_parsed = URI.parse(url) 
      
      @response = Net::HTTP.start(url_parsed.host, url_parsed.port) {|http| 
            req = http.get('/', {'Authorization' => @authorization, 'Accept' => @accept }) 
      }
  end

I don't have any problem. What can be the difference between them ?

Anthony.

2011/7/28 Archiloque <code@...>
The authorization is in the header so you'll have to be sure the value is ok and perhaps check with the service provider

A.




Le 28 juil. 2011 à 10:19, Anthony Roux <m.roux.a@...> a écrit :

Hello,


RestClient.get "http://55.7.28.210:4321/TSI-Dev/", "Accept"=>"text/plain", "Accept-Encoding"=>"gzip, deflate", "Authorization"=>"Basic YW50aG9ueTphbnRob255", "Content-Type"=>"text/plain"
# => 500 InternalServerError | text/html 847 bytes

Anthony.

2011/7/27 Archiloque <code@...>
Normally RestClient.get "my_url", :accept => @accept, :content_type => @content_type, :authorization => @authorization should work as expected, could you activate the log (RestClient.log = 'stdout') and send me the resulting request ?

A.

Le 27 juil. 2011 à 16:46, Anthony Roux a écrit :

Hello Manuel, thanks for your answer,

I don't have the user and password. I mean i can get it but I prefer work with the token that i already have. I just need a way to put my authorization to the header.

Anthony.

2011/7/27 Manuel Palenciano <mpalenciano@...>
Hello Anthony,

I think you put that in the URL

'user:passwd@your_url'

Manuel

On Jul 27, 2011, at 4:36 PM, Anthony Roux wrote:

Hello,

I'm using rest-client to manage lot's of my applications. Since now they didn't had any sort of authentication. I just finished to deploy it, so i need to be able to interact (though an API) between my applications despite they need to be authenticate. The problem is i can't find a way to put my authorization on the headers on a get :

I would like to be able to do something like that : 

@response = RestClient.get "my_url", :accept => @accept, :content_type => @content_type, :authorization => @authorization 

But i always have an error 500...

Sincerely, 
Anthony Roux.







Anthony Roux <m.roux.a@...>
 

Thanks for your answer,

Request headers :

With net/http from ruby (that works)
  def get_response_with_auth(url)
      url_parsed = URI.parse(url) 
      
      @response = Net::HTTP.start(url_parsed.host, url_parsed.port) {|http| 
            @req = http.get('/', {'Authorization' => @authorization, 'Accept' => @accept})
      }
  end

GET /user-profil-manager/ HTTP/1.1 
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/5.0 
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 
Accept-Language: fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3 
Accept-Encoding: gzip, deflate 
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 
Connection: keep-alive 
Cookie: ... 
Authorization: Basic YW50aG9ueTphbnRob255
------------------------------------------------
With rest-client (not works) : 
 @responses = RestClient.get "http://55.7.28.210:4321/TSI-Dev/", :accept => @accept, :authorization => @authorization

GET /user-profil-manager/ HTTP/1.1
User-Agent Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/5.0
Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding gzip, deflate
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
Connection keep-alive
Cookie ....
Authorization Basic YW50aG9ueTphbnRob255

I do not understand...

Anthony.


2011/7/28 Archiloque <code@...>

Is authorization a String ? It may be the way it transform it into a String

You could try starting a simple local rack app that logs your requests' headers and execute both resquests against it and check if you see any difference ?

A.




Le 28 juil. 2011 à 10:35, Anthony Roux <m.roux.a@...> a écrit :

If I use this method : 

def get_response_with_auth(url)
      url_parsed = URI.parse(url) 
      
      @response = Net::HTTP.start(url_parsed.host, url_parsed.port) {|http| 
            req = http.get('/', {'Authorization' => @authorization, 'Accept' => @accept }) 
      }
  end

I don't have any problem. What can be the difference between them ?

Anthony.

2011/7/28 Archiloque <code@...>
The authorization is in the header so you'll have to be sure the value is ok and perhaps check with the service provider

A.




Le 28 juil. 2011 à 10:19, Anthony Roux <m.roux.a@...> a écrit :

Hello,


RestClient.get "http://55.7.28.210:4321/TSI-Dev/", "Accept"=>"text/plain", "Accept-Encoding"=>"gzip, deflate", "Authorization"=>"Basic YW50aG9ueTphbnRob255", "Content-Type"=>"text/plain"
# => 500 InternalServerError | text/html 847 bytes

Anthony.

2011/7/27 Archiloque <code@...>
Normally RestClient.get "my_url", :accept => @accept, :content_type => @content_type, :authorization => @authorization should work as expected, could you activate the log (RestClient.log = 'stdout') and send me the resulting request ?

A.

Le 27 juil. 2011 à 16:46, Anthony Roux a écrit :

Hello Manuel, thanks for your answer,

I don't have the user and password. I mean i can get it but I prefer work with the token that i already have. I just need a way to put my authorization to the header.

Anthony.

2011/7/27 Manuel Palenciano <mpalenciano@...>
Hello Anthony,

I think you put that in the URL

'user:passwd@your_url'

Manuel

On Jul 27, 2011, at 4:36 PM, Anthony Roux wrote:

Hello,

I'm using rest-client to manage lot's of my applications. Since now they didn't had any sort of authentication. I just finished to deploy it, so i need to be able to interact (though an API) between my applications despite they need to be authenticate. The problem is i can't find a way to put my authorization on the headers on a get :

I would like to be able to do something like that : 

@response = RestClient.get "my_url", :accept => @accept, :content_type => @content_type, :authorization => @authorization 

But i always have an error 500...

Sincerely, 
Anthony Roux.








Archiloque <code@...>
 


Both report a Firefox user agent and other headers that you don't setup in the displayed code -> could you paste the actual code ?

A.



Le 28 juil. 2011 à 15:21, Anthony Roux <m.roux.a@...> a écrit :

Thanks for your answer,

Request headers :

With net/http from ruby (that works)
  def get_response_with_auth(url)
      url_parsed = URI.parse(url) 
      
      @response = Net::HTTP.start(url_parsed.host, url_parsed.port) {|http| 
            @req = http.get('/', {'Authorization' => @authorization, 'Accept' => @accept})
      }
  end

GET /user-profil-manager/ HTTP/1.1 
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/5.0 
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 
Accept-Language: fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3 
Accept-Encoding: gzip, deflate 
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 
Connection: keep-alive 
Cookie: ... 
Authorization: Basic YW50aG9ueTphbnRob255
------------------------------------------------
With rest-client (not works) : 
 @responses = RestClient.get "http://55.7.28.210:4321/TSI-Dev/", :accept => @accept, :authorization => @authorization

GET /user-profil-manager/ HTTP/1.1
User-Agent Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/5.0
Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding gzip, deflate
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
Connection keep-alive
Cookie ....
Authorization Basic YW50aG9ueTphbnRob255

I do not understand...

Anthony.


2011/7/28 Archiloque <code@...>
Is authorization a String ? It may be the way it transform it into a String

You could try starting a simple local rack app that logs your requests' headers and execute both resquests against it and check if you see any difference ?

A.




Le 28 juil. 2011 à 10:35, Anthony Roux <m.roux.a@...> a écrit :

If I use this method : 

def get_response_with_auth(url)
      url_parsed = URI.parse(url) 
      
      @response = Net::HTTP.start(url_parsed.host, url_parsed.port) {|http| 
            req = http.get('/', {'Authorization' => @authorization, 'Accept' => @accept }) 
      }
  end

I don't have any problem. What can be the difference between them ?

Anthony.

2011/7/28 Archiloque <code@...>
The authorization is in the header so you'll have to be sure the value is ok and perhaps check with the service provider

A.




Le 28 juil. 2011 à 10:19, Anthony Roux <m.roux.a@...> a écrit :

Hello,


RestClient.get "http://55.7.28.210:4321/TSI-Dev/", "Accept"=>"text/plain", "Accept-Encoding"=>"gzip, deflate", "Authorization"=>"Basic YW50aG9ueTphbnRob255", "Content-Type"=>"text/plain"
# => 500 InternalServerError | text/html 847 bytes

Anthony.

2011/7/27 Archiloque <code@...>
Normally RestClient.get "my_url", :accept => @accept, :content_type => @content_type, :authorization => @authorization should work as expected, could you activate the log (RestClient.log = 'stdout') and send me the resulting request ?

A.

Le 27 juil. 2011 à 16:46, Anthony Roux a écrit :

Hello Manuel, thanks for your answer,

I don't have the user and password. I mean i can get it but I prefer work with the token that i already have. I just need a way to put my authorization to the header.

Anthony.

2011/7/27 Manuel Palenciano <mpalenciano@...>
Hello Anthony,

I think you put that in the URL

'user:passwd@your_url'

Manuel

On Jul 27, 2011, at 4:36 PM, Anthony Roux wrote:

Hello,

I'm using rest-client to manage lot's of my applications. Since now they didn't had any sort of authentication. I just finished to deploy it, so i need to be able to interact (though an API) between my applications despite they need to be authenticate. The problem is i can't find a way to put my authorization on the headers on a get :

I would like to be able to do something like that : 

@response = RestClient.get "my_url", :accept => @accept, :content_type => @content_type, :authorization => @authorization 

But i always have an error 500...

Sincerely, 
Anthony Roux.








Anthony Roux <m.roux.a@...>
 

I want to interact with another rails application. This application checks if we are already logged before authorize using it through API. To do it i have to set Authorization in the header. 
I use Apache Basic authentication.

Here you can find my home controller http://pastebin.com/iKCwLm8w

If i use  get_response_with_auth(url) instead of RestClient it works. 
If i use RestClient without set authorization i have an HTTP error 401 Unauthorized
if i use RestClient exaclty as the screenshot i have HTTP error 500

Anthony.

2011/7/28 Archiloque <code@...>


Both report a Firefox user agent and other headers that you don't setup in the displayed code -> could you paste the actual code ?

A.



Le 28 juil. 2011 à 15:21, Anthony Roux <m.roux.a@...> a écrit :

Thanks for your answer,

Request headers :

With net/http from ruby (that works)
  def get_response_with_auth(url)
      url_parsed = URI.parse(url) 
      
      @response = Net::HTTP.start(url_parsed.host, url_parsed.port) {|http| 
            @req = http.get('/', {'Authorization' => @authorization, 'Accept' => @accept})
      }
  end

GET /user-profil-manager/ HTTP/1.1 
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/5.0 
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 
Accept-Language: fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3 
Accept-Encoding: gzip, deflate 
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 
Connection: keep-alive 
Cookie: ... 
Authorization: Basic YW50aG9ueTphbnRob255
------------------------------------------------
With rest-client (not works) : 
 @responses = RestClient.get "http://55.7.28.210:4321/TSI-Dev/", :accept => @accept, :authorization => @authorization

GET /user-profil-manager/ HTTP/1.1
User-Agent Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/5.0
Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding gzip, deflate
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
Connection keep-alive
Cookie ....
Authorization Basic YW50aG9ueTphbnRob255

I do not understand...

Anthony.


2011/7/28 Archiloque <code@...>
Is authorization a String ? It may be the way it transform it into a String

You could try starting a simple local rack app that logs your requests' headers and execute both resquests against it and check if you see any difference ?

A.




Le 28 juil. 2011 à 10:35, Anthony Roux <m.roux.a@...> a écrit :

If I use this method : 

def get_response_with_auth(url)
      url_parsed = URI.parse(url) 
      
      @response = Net::HTTP.start(url_parsed.host, url_parsed.port) {|http| 
            req = http.get('/', {'Authorization' => @authorization, 'Accept' => @accept }) 
      }
  end

I don't have any problem. What can be the difference between them ?

Anthony.

2011/7/28 Archiloque <code@...>
The authorization is in the header so you'll have to be sure the value is ok and perhaps check with the service provider

A.




Le 28 juil. 2011 à 10:19, Anthony Roux <m.roux.a@...> a écrit :

Hello,


RestClient.get "http://55.7.28.210:4321/TSI-Dev/", "Accept"=>"text/plain", "Accept-Encoding"=>"gzip, deflate", "Authorization"=>"Basic YW50aG9ueTphbnRob255", "Content-Type"=>"text/plain"
# => 500 InternalServerError | text/html 847 bytes

Anthony.

2011/7/27 Archiloque <code@...>
Normally RestClient.get "my_url", :accept => @accept, :content_type => @content_type, :authorization => @authorization should work as expected, could you activate the log (RestClient.log = 'stdout') and send me the resulting request ?

A.

Le 27 juil. 2011 à 16:46, Anthony Roux a écrit :

Hello Manuel, thanks for your answer,

I don't have the user and password. I mean i can get it but I prefer work with the token that i already have. I just need a way to put my authorization to the header.

Anthony.

2011/7/27 Manuel Palenciano <mpalenciano@...>
Hello Anthony,

I think you put that in the URL

'user:passwd@your_url'

Manuel

On Jul 27, 2011, at 4:36 PM, Anthony Roux wrote:

Hello,

I'm using rest-client to manage lot's of my applications. Since now they didn't had any sort of authentication. I just finished to deploy it, so i need to be able to interact (though an API) between my applications despite they need to be authenticate. The problem is i can't find a way to put my authorization on the headers on a get :

I would like to be able to do something like that : 

@response = RestClient.get "my_url", :accept => @accept, :content_type => @content_type, :authorization => @authorization 

But i always have an error 500...

Sincerely, 
Anthony Roux.









Archiloque <code@...>
 

From what I understand the logs you provided don't come from the requests from http or from rest-client but are requests from Firefox. Am I right and in this case could you send me the header logs from the ruby requests ?

A.




Le 28 juil. 2011 à 15:56, Anthony Roux <m.roux.a@...> a écrit :

I want to interact with another rails application. This application checks if we are already logged before authorize using it through API. To do it i have to set Authorization in the header. 
I use Apache Basic authentication.

Here you can find my home controller http://pastebin.com/iKCwLm8w

If i use  get_response_with_auth(url) instead of RestClient it works. 
If i use RestClient without set authorization i have an HTTP error 401 Unauthorized
if i use RestClient exaclty as the screenshot i have HTTP error 500

Anthony.

2011/7/28 Archiloque <code@...>

Both report a Firefox user agent and other headers that you don't setup in the displayed code -> could you paste the actual code ?

A.



Le 28 juil. 2011 à 15:21, Anthony Roux <m.roux.a@...> a écrit :

Thanks for your answer,

Request headers :

With net/http from ruby (that works)
  def get_response_with_auth(url)
      url_parsed = URI.parse(url) 
      
      @response = Net::HTTP.start(url_parsed.host, url_parsed.port) {|http| 
            @req = http.get('/', {'Authorization' => @authorization, 'Accept' => @accept})
      }
  end

GET /user-profil-manager/ HTTP/1.1 
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/5.0 
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 
Accept-Language: fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3 
Accept-Encoding: gzip, deflate 
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 
Connection: keep-alive 
Cookie: ... 
Authorization: Basic YW50aG9ueTphbnRob255
------------------------------------------------
With rest-client (not works) : 
 @responses = RestClient.get "http://55.7.28.210:4321/TSI-Dev/", :accept => @accept, :authorization => @authorization

GET /user-profil-manager/ HTTP/1.1
User-Agent Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/5.0
Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding gzip, deflate
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
Connection keep-alive
Cookie ....
Authorization Basic YW50aG9ueTphbnRob255

I do not understand...

Anthony.


2011/7/28 Archiloque <code@...>
Is authorization a String ? It may be the way it transform it into a String

You could try starting a simple local rack app that logs your requests' headers and execute both resquests against it and check if you see any difference ?

A.




Le 28 juil. 2011 à 10:35, Anthony Roux <m.roux.a@...> a écrit :

If I use this method : 

def get_response_with_auth(url)
      url_parsed = URI.parse(url) 
      
      @response = Net::HTTP.start(url_parsed.host, url_parsed.port) {|http| 
            req = http.get('/', {'Authorization' => @authorization, 'Accept' => @accept }) 
      }
  end

I don't have any problem. What can be the difference between them ?

Anthony.

2011/7/28 Archiloque <code@...>
The authorization is in the header so you'll have to be sure the value is ok and perhaps check with the service provider

A.




Le 28 juil. 2011 à 10:19, Anthony Roux <m.roux.a@...> a écrit :

Hello,


RestClient.get "http://55.7.28.210:4321/TSI-Dev/", "Accept"=>"text/plain", "Accept-Encoding"=>"gzip, deflate", "Authorization"=>"Basic YW50aG9ueTphbnRob255", "Content-Type"=>"text/plain"
# => 500 InternalServerError | text/html 847 bytes

Anthony.

2011/7/27 Archiloque <code@...>
Normally RestClient.get "my_url", :accept => @accept, :content_type => @content_type, :authorization => @authorization should work as expected, could you activate the log (RestClient.log = 'stdout') and send me the resulting request ?

A.

Le 27 juil. 2011 à 16:46, Anthony Roux a écrit :

Hello Manuel, thanks for your answer,

I don't have the user and password. I mean i can get it but I prefer work with the token that i already have. I just need a way to put my authorization to the header.

Anthony.

2011/7/27 Manuel Palenciano <mpalenciano@...>
Hello Anthony,

I think you put that in the URL

'user:passwd@your_url'

Manuel

On Jul 27, 2011, at 4:36 PM, Anthony Roux wrote:

Hello,

I'm using rest-client to manage lot's of my applications. Since now they didn't had any sort of authentication. I just finished to deploy it, so i need to be able to interact (though an API) between my applications despite they need to be authenticate. The problem is i can't find a way to put my authorization on the headers on a get :

I would like to be able to do something like that : 

@response = RestClient.get "my_url", :accept => @accept, :content_type => @content_type, :authorization => @authorization 

But i always have an error 500...

Sincerely, 
Anthony Roux.









Anthony Roux <m.roux.a@...>
 

Yes you are right, they come from Firebug.

For rest-client : 

RestClient.get "http://55.7.28.210:4321/TSI-Dev/", "Accept"=>"text/plain", "Accept-Encoding"=>"gzip, deflate", "Authorization"=>"Basic YW50aG9ueTphbnRob255", "Referer"=>"http://55.7.28.210:4321/user-profil-manager/"
# => 500 InternalServerError | text/html 847 bytes
-------------------------------------------------------------------------------
With this code : 

I have :


Anthony.


2011/7/28 Archiloque <code@...>

From what I understand the logs you provided don't come from the requests from http or from rest-client but are requests from Firefox. Am I right and in this case could you send me the header logs from the ruby requests ?

A.




Le 28 juil. 2011 à 15:56, Anthony Roux <m.roux.a@...> a écrit :

I want to interact with another rails application. This application checks if we are already logged before authorize using it through API. To do it i have to set Authorization in the header. 
I use Apache Basic authentication.

Here you can find my home controller http://pastebin.com/iKCwLm8w

If i use  get_response_with_auth(url) instead of RestClient it works. 
If i use RestClient without set authorization i have an HTTP error 401 Unauthorized
if i use RestClient exaclty as the screenshot i have HTTP error 500

Anthony.

2011/7/28 Archiloque <code@...>

Both report a Firefox user agent and other headers that you don't setup in the displayed code -> could you paste the actual code ?

A.



Le 28 juil. 2011 à 15:21, Anthony Roux <m.roux.a@...> a écrit :

Thanks for your answer,

Request headers :

With net/http from ruby (that works)
  def get_response_with_auth(url)
      url_parsed = URI.parse(url) 
      
      @response = Net::HTTP.start(url_parsed.host, url_parsed.port) {|http| 
            @req = http.get('/', {'Authorization' => @authorization, 'Accept' => @accept})
      }
  end

GET /user-profil-manager/ HTTP/1.1 
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/5.0 
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 
Accept-Language: fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3 
Accept-Encoding: gzip, deflate 
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 
Connection: keep-alive 
Cookie: ... 
Authorization: Basic YW50aG9ueTphbnRob255
------------------------------------------------
With rest-client (not works) : 
 @responses = RestClient.get "http://55.7.28.210:4321/TSI-Dev/", :accept => @accept, :authorization => @authorization

GET /user-profil-manager/ HTTP/1.1
User-Agent Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/5.0
Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding gzip, deflate
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
Connection keep-alive
Cookie ....
Authorization Basic YW50aG9ueTphbnRob255

I do not understand...

Anthony.


2011/7/28 Archiloque <code@...>
Is authorization a String ? It may be the way it transform it into a String

You could try starting a simple local rack app that logs your requests' headers and execute both resquests against it and check if you see any difference ?

A.




Le 28 juil. 2011 à 10:35, Anthony Roux <m.roux.a@...> a écrit :

If I use this method : 

def get_response_with_auth(url)
      url_parsed = URI.parse(url) 
      
      @response = Net::HTTP.start(url_parsed.host, url_parsed.port) {|http| 
            req = http.get('/', {'Authorization' => @authorization, 'Accept' => @accept }) 
      }
  end

I don't have any problem. What can be the difference between them ?

Anthony.

2011/7/28 Archiloque <code@...>
The authorization is in the header so you'll have to be sure the value is ok and perhaps check with the service provider

A.




Le 28 juil. 2011 à 10:19, Anthony Roux <m.roux.a@...> a écrit :

Hello,


RestClient.get "http://55.7.28.210:4321/TSI-Dev/", "Accept"=>"text/plain", "Accept-Encoding"=>"gzip, deflate", "Authorization"=>"Basic YW50aG9ueTphbnRob255", "Content-Type"=>"text/plain"
# => 500 InternalServerError | text/html 847 bytes

Anthony.

2011/7/27 Archiloque <code@...>
Normally RestClient.get "my_url", :accept => @accept, :content_type => @content_type, :authorization => @authorization should work as expected, could you activate the log (RestClient.log = 'stdout') and send me the resulting request ?

A.

Le 27 juil. 2011 à 16:46, Anthony Roux a écrit :

Hello Manuel, thanks for your answer,

I don't have the user and password. I mean i can get it but I prefer work with the token that i already have. I just need a way to put my authorization to the header.

Anthony.

2011/7/27 Manuel Palenciano <mpalenciano@...>
Hello Anthony,

I think you put that in the URL

'user:passwd@your_url'

Manuel

On Jul 27, 2011, at 4:36 PM, Anthony Roux wrote:

Hello,

I'm using rest-client to manage lot's of my applications. Since now they didn't had any sort of authentication. I just finished to deploy it, so i need to be able to interact (though an API) between my applications despite they need to be authenticate. The problem is i can't find a way to put my authorization on the headers on a get :

I would like to be able to do something like that : 

@response = RestClient.get "my_url", :accept => @accept, :content_type => @content_type, :authorization => @authorization 

But i always have an error 500...

Sincerely, 
Anthony Roux.










Anthony Roux <m.roux.a@...>
 

It seems that i solved the problem by setting HTTP accept to '*/*'...

Thanks a lot for your responses.

Anthony.

2011/7/29 Anthony Roux <m.roux.a@...>

Yes you are right, they come from Firebug.

For rest-client : 

RestClient.get "http://55.7.28.210:4321/TSI-Dev/", "Accept"=>"text/plain", "Accept-Encoding"=>"gzip, deflate", "Authorization"=>"Basic YW50aG9ueTphbnRob255", "Referer"=>"http://55.7.28.210:4321/user-profil-manager/"
# => 500 InternalServerError | text/html 847 bytes
-------------------------------------------------------------------------------
With this code : 

I have :


Anthony.


2011/7/28 Archiloque <code@...>
From what I understand the logs you provided don't come from the requests from http or from rest-client but are requests from Firefox. Am I right and in this case could you send me the header logs from the ruby requests ?

A.




Le 28 juil. 2011 à 15:56, Anthony Roux <m.roux.a@...> a écrit :

I want to interact with another rails application. This application checks if we are already logged before authorize using it through API. To do it i have to set Authorization in the header. 
I use Apache Basic authentication.

Here you can find my home controller http://pastebin.com/iKCwLm8w

If i use  get_response_with_auth(url) instead of RestClient it works. 
If i use RestClient without set authorization i have an HTTP error 401 Unauthorized
if i use RestClient exaclty as the screenshot i have HTTP error 500

Anthony.

2011/7/28 Archiloque <code@...>

Both report a Firefox user agent and other headers that you don't setup in the displayed code -> could you paste the actual code ?

A.



Le 28 juil. 2011 à 15:21, Anthony Roux <m.roux.a@...> a écrit :

Thanks for your answer,

Request headers :

With net/http from ruby (that works)
  def get_response_with_auth(url)
      url_parsed = URI.parse(url) 
      
      @response = Net::HTTP.start(url_parsed.host, url_parsed.port) {|http| 
            @req = http.get('/', {'Authorization' => @authorization, 'Accept' => @accept})
      }
  end

GET /user-profil-manager/ HTTP/1.1 
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/5.0 
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 
Accept-Language: fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3 
Accept-Encoding: gzip, deflate 
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 
Connection: keep-alive 
Cookie: ... 
Authorization: Basic YW50aG9ueTphbnRob255
------------------------------------------------
With rest-client (not works) : 
 @responses = RestClient.get "http://55.7.28.210:4321/TSI-Dev/", :accept => @accept, :authorization => @authorization

GET /user-profil-manager/ HTTP/1.1
User-Agent Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/5.0
Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding gzip, deflate
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
Connection keep-alive
Cookie ....
Authorization Basic YW50aG9ueTphbnRob255

I do not understand...

Anthony.


2011/7/28 Archiloque <code@...>
Is authorization a String ? It may be the way it transform it into a String

You could try starting a simple local rack app that logs your requests' headers and execute both resquests against it and check if you see any difference ?

A.




Le 28 juil. 2011 à 10:35, Anthony Roux <m.roux.a@...> a écrit :

If I use this method : 

def get_response_with_auth(url)
      url_parsed = URI.parse(url) 
      
      @response = Net::HTTP.start(url_parsed.host, url_parsed.port) {|http| 
            req = http.get('/', {'Authorization' => @authorization, 'Accept' => @accept }) 
      }
  end

I don't have any problem. What can be the difference between them ?

Anthony.

2011/7/28 Archiloque <code@...>
The authorization is in the header so you'll have to be sure the value is ok and perhaps check with the service provider

A.




Le 28 juil. 2011 à 10:19, Anthony Roux <m.roux.a@...> a écrit :

Hello,


RestClient.get "http://55.7.28.210:4321/TSI-Dev/", "Accept"=>"text/plain", "Accept-Encoding"=>"gzip, deflate", "Authorization"=>"Basic YW50aG9ueTphbnRob255", "Content-Type"=>"text/plain"
# => 500 InternalServerError | text/html 847 bytes

Anthony.

2011/7/27 Archiloque <code@...>
Normally RestClient.get "my_url", :accept => @accept, :content_type => @content_type, :authorization => @authorization should work as expected, could you activate the log (RestClient.log = 'stdout') and send me the resulting request ?

A.

Le 27 juil. 2011 à 16:46, Anthony Roux a écrit :

Hello Manuel, thanks for your answer,

I don't have the user and password. I mean i can get it but I prefer work with the token that i already have. I just need a way to put my authorization to the header.

Anthony.

2011/7/27 Manuel Palenciano <mpalenciano@...>
Hello Anthony,

I think you put that in the URL

'user:passwd@your_url'

Manuel

On Jul 27, 2011, at 4:36 PM, Anthony Roux wrote:

Hello,

I'm using rest-client to manage lot's of my applications. Since now they didn't had any sort of authentication. I just finished to deploy it, so i need to be able to interact (though an API) between my applications despite they need to be authenticate. The problem is i can't find a way to put my authorization on the headers on a get :

I would like to be able to do something like that : 

@response = RestClient.get "my_url", :accept => @accept, :content_type => @content_type, :authorization => @authorization 

But i always have an error 500...

Sincerely, 
Anthony Roux.











Archiloque <code@...>
 

Damn, didn't though of that, in a perfect world we would have servers that send useful error messages, or even know about http error code (isn't 406 made for this ?).

A.




Le 1 août 2011 à 09:27, Anthony Roux <m.roux.a@...> a écrit :

It seems that i solved the problem by setting HTTP accept to '*/*'...

Thanks a lot for your responses.

Anthony.

2011/7/29 Anthony Roux <m.roux.a@...>
Yes you are right, they come from Firebug.

For rest-client : 

RestClient.get "http://55.7.28.210:4321/TSI-Dev/", "Accept"=>"text/plain", "Accept-Encoding"=>"gzip, deflate", "Authorization"=>"Basic YW50aG9ueTphbnRob255", "Referer"=>"http://55.7.28.210:4321/user-profil-manager/"
# => 500 InternalServerError | text/html 847 bytes
-------------------------------------------------------------------------------
With this code : 

I have :


Anthony.


2011/7/28 Archiloque <code@...>
From what I understand the logs you provided don't come from the requests from http or from rest-client but are requests from Firefox. Am I right and in this case could you send me the header logs from the ruby requests ?

A.




Le 28 juil. 2011 à 15:56, Anthony Roux <m.roux.a@...> a écrit :

I want to interact with another rails application. This application checks if we are already logged before authorize using it through API. To do it i have to set Authorization in the header. 
I use Apache Basic authentication.

Here you can find my home controller http://pastebin.com/iKCwLm8w

If i use  get_response_with_auth(url) instead of RestClient it works. 
If i use RestClient without set authorization i have an HTTP error 401 Unauthorized
if i use RestClient exaclty as the screenshot i have HTTP error 500

Anthony.

2011/7/28 Archiloque <code@...>

Both report a Firefox user agent and other headers that you don't setup in the displayed code -> could you paste the actual code ?

A.



Le 28 juil. 2011 à 15:21, Anthony Roux <m.roux.a@...> a écrit :

Thanks for your answer,

Request headers :

With net/http from ruby (that works)
  def get_response_with_auth(url)
      url_parsed = URI.parse(url) 
      
      @response = Net::HTTP.start(url_parsed.host, url_parsed.port) {|http| 
            @req = http.get('/', {'Authorization' => @authorization, 'Accept' => @accept})
      }
  end

GET /user-profil-manager/ HTTP/1.1 
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/5.0 
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 
Accept-Language: fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3 
Accept-Encoding: gzip, deflate 
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 
Connection: keep-alive 
Cookie: ... 
Authorization: Basic YW50aG9ueTphbnRob255
------------------------------------------------
With rest-client (not works) : 
 @responses = RestClient.get "http://55.7.28.210:4321/TSI-Dev/", :accept => @accept, :authorization => @authorization

GET /user-profil-manager/ HTTP/1.1
User-Agent Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/5.0
Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding gzip, deflate
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
Connection keep-alive
Cookie ....
Authorization Basic YW50aG9ueTphbnRob255

I do not understand...

Anthony.


2011/7/28 Archiloque <code@...>
Is authorization a String ? It may be the way it transform it into a String

You could try starting a simple local rack app that logs your requests' headers and execute both resquests against it and check if you see any difference ?

A.




Le 28 juil. 2011 à 10:35, Anthony Roux <m.roux.a@...> a écrit :

If I use this method : 

def get_response_with_auth(url)
      url_parsed = URI.parse(url) 
      
      @response = Net::HTTP.start(url_parsed.host, url_parsed.port) {|http| 
            req = http.get('/', {'Authorization' => @authorization, 'Accept' => @accept }) 
      }
  end

I don't have any problem. What can be the difference between them ?

Anthony.

2011/7/28 Archiloque <code@...>
The authorization is in the header so you'll have to be sure the value is ok and perhaps check with the service provider

A.




Le 28 juil. 2011 à 10:19, Anthony Roux <m.roux.a@...> a écrit :

Hello,


RestClient.get "http://55.7.28.210:4321/TSI-Dev/", "Accept"=>"text/plain", "Accept-Encoding"=>"gzip, deflate", "Authorization"=>"Basic YW50aG9ueTphbnRob255", "Content-Type"=>"text/plain"
# => 500 InternalServerError | text/html 847 bytes

Anthony.

2011/7/27 Archiloque <code@...>
Normally RestClient.get "my_url", :accept => @accept, :content_type => @content_type, :authorization => @authorization should work as expected, could you activate the log (RestClient.log = 'stdout') and send me the resulting request ?

A.

Le 27 juil. 2011 à 16:46, Anthony Roux a écrit :

Hello Manuel, thanks for your answer,

I don't have the user and password. I mean i can get it but I prefer work with the token that i already have. I just need a way to put my authorization to the header.

Anthony.

2011/7/27 Manuel Palenciano <mpalenciano@...>
Hello Anthony,

I think you put that in the URL

'user:passwd@your_url'

Manuel

On Jul 27, 2011, at 4:36 PM, Anthony Roux wrote:

Hello,

I'm using rest-client to manage lot's of my applications. Since now they didn't had any sort of authentication. I just finished to deploy it, so i need to be able to interact (though an API) between my applications despite they need to be authenticate. The problem is i can't find a way to put my authorization on the headers on a get :

I would like to be able to do something like that : 

@response = RestClient.get "my_url", :accept => @accept, :content_type => @content_type, :authorization => @authorization 

But i always have an error 500...

Sincerely, 
Anthony Roux.