Using HTTPHeaders for basic authentification

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
kolia
Posts: 82
Joined: Thu May 28, 2015 3:53 pm

Using HTTPHeaders for basic authentification

Post by kolia » Tue Sep 08, 2015 4:31 pm

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
Nicolas
LC 7.1 on Windows 8.1 and on MAC OS 10.10.5 Xcode 6.4 - 7.1

pink
Posts: 280
Joined: Wed Mar 12, 2014 6:18 pm

Re: Using HTTPHeaders for basic authentification

Post by pink » Wed Sep 16, 2015 2:58 pm

it looks correct to me, is that the only httpHeader that you are setting?
Greg (pink) Miller

MadPink, LLC
I'm Mad, Pink and Dangerous to Know

kolia
Posts: 82
Joined: Thu May 28, 2015 3:53 pm

Re: Using HTTPHeaders for basic authentification

Post by kolia » Wed Sep 16, 2015 4:41 pm

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
Nicolas
LC 7.1 on Windows 8.1 and on MAC OS 10.10.5 Xcode 6.4 - 7.1

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Using HTTPHeaders for basic authentification

Post by FourthWorld » Wed Sep 16, 2015 5:44 pm

I've used Basic HTTP Authentication successfully without having to alter the request header.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

kolia
Posts: 82
Joined: Thu May 28, 2015 3:53 pm

Re: Using HTTPHeaders for basic authentification

Post by kolia » Wed Sep 16, 2015 5:49 pm

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
Nicolas
LC 7.1 on Windows 8.1 and on MAC OS 10.10.5 Xcode 6.4 - 7.1

pink
Posts: 280
Joined: Wed Mar 12, 2014 6:18 pm

Re: Using HTTPHeaders for basic authentification

Post by pink » Wed Sep 16, 2015 5:59 pm

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.
Greg (pink) Miller

MadPink, LLC
I'm Mad, Pink and Dangerous to Know

kolia
Posts: 82
Joined: Thu May 28, 2015 3:53 pm

Re: Using HTTPHeaders for basic authentification

Post by kolia » Wed Sep 16, 2015 6:01 pm

ok as you said I'll give a shot
Nicolas
Nicolas
LC 7.1 on Windows 8.1 and on MAC OS 10.10.5 Xcode 6.4 - 7.1

Post Reply