Page 1 of 1
Using HTTPHeaders for basic authentification
Posted: Tue Sep 08, 2015 4:31 pm
by kolia
Hello,
I'm trying to set HTTPHeaders property in order to perform authentification.
Here is the line of code
Code: Select all
set the httpHeaders to "Authorization: Basic " && base64Encode("user:password")
It does not work whereas
Code: Select all
put url "http://user:password@192.168.21.251/globalstatus.xml" into response
Could someone show me the right way to do it?
Thank you
Re: Using HTTPHeaders for basic authentification
Posted: Wed Sep 16, 2015 2:58 pm
by pink
it looks correct to me, is that the only httpHeader that you are setting?
Re: Using HTTPHeaders for basic authentification
Posted: Wed Sep 16, 2015 4:41 pm
by kolia
Hi Greg,
Yes this is the only header I set, and it does not work. The problem might be other party. I've no clue how to troubleshoot that
Nicolas
Re: Using HTTPHeaders for basic authentification
Posted: Wed Sep 16, 2015 5:44 pm
by FourthWorld
I've used Basic HTTP Authentication successfully without having to alter the request header.
Re: Using HTTPHeaders for basic authentification
Posted: Wed Sep 16, 2015 5:49 pm
by kolia
Hi Richard,
I've used Basic HTTP Authentication successfully without having to alter the request header.
I'm not an HTML guru. Could you elaborate a bit?
If I understand well setting the header permits to send a regular http request without having to put user:password@ before the URL. Am I correct?
Thanks
Nicolas
Re: Using HTTPHeaders for basic authentification
Posted: Wed Sep 16, 2015 5:59 pm
by pink
One minor thing is that you end up having an extra space in the header with what you pasted in:
Code: Select all
set the httpHeaders to "Authorization: Basic " && base64Encode("user:password")
You have a space between the word Basic and the quotation marks, and then you use && which also adds a space
try
Code: Select all
put "Authorization: Basic" && base64Encode("user:password") into tHeader
set the httpHeaders to tHeader
I honestly am not sure if that would cause a problem but it's worth a shot.
Re: Using HTTPHeaders for basic authentification
Posted: Wed Sep 16, 2015 6:01 pm
by kolia
ok as you said I'll give a shot
Nicolas