Hello,
I have to perform a Basic Access Authentication against protocol specified in RFC 2617 in order to use an HTTP API. I have the feeling that I should use the httpHeaders keyword but I have no clue on how to do it. I have to send user and password to the server in order to use the API. Can someone show the path?
Thank you
Nicolas
Perform Basic Access Authentication
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Perform Basic Access Authentication
Nicolas
LC 7.1 on Windows 8.1 and on MAC OS 10.10.5 Xcode 6.4 - 7.1
LC 7.1 on Windows 8.1 and on MAC OS 10.10.5 Xcode 6.4 - 7.1
-
FourthWorld
- VIP Livecode Opensource Backer

- Posts: 10103
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Perform Basic Access Authentication
HTTP Basic Authentication has many options for different scenarios, but the most commonly-used way for clients to provide credentials is to embed them in the URL in this form, without requiring us to make explicit header changes:
http://username@password:www.domain.com/resource
What error do you get when you try that? And are you using GET or POST?
http://username@password:www.domain.com/resource
What error do you get when you try that? And are you using GET or POST?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Perform Basic Access Authentication
Thanks FourthWorld
This method I do know does not work in that case. I guess I have to send the credentials with headers instruction that I'm not familiar with. I used base64 encoding of username:password, but this does not work so far. I sniffed the http header and the credentials don't seem to be part of the stream. I use Put URL httpRequest
Nicolas
This method I do know does not work in that case. I guess I have to send the credentials with headers instruction that I'm not familiar with. I used base64 encoding of username:password, but this does not work so far. I sniffed the http header and the credentials don't seem to be part of the stream. I use Put URL httpRequest
Nicolas
Nicolas
LC 7.1 on Windows 8.1 and on MAC OS 10.10.5 Xcode 6.4 - 7.1
LC 7.1 on Windows 8.1 and on MAC OS 10.10.5 Xcode 6.4 - 7.1
Re: Perform Basic Access Authentication
Hi, this is what i use and it works for me. You might have been missing the auth type of basic or missing a colon space, minor things like that can trip up things.
edit: changed + to &
Code: Select all
put "https://" & myServer & "/api/xxxxxx/?q=" & urlencode(searchTerm) into myURL
put base64encode("user:password") into userpass
put "Authorization: Basic " & userpass into UserAuth
set the httpHeaders to UserAuth
put URL myURL into myResponse
Last edited by scrabbles on Mon Oct 05, 2015 1:54 am, edited 1 time in total.
Re: Perform Basic Access Authentication
Thanks so much scrabbles, as you said, a simple missing character was the culprit.
For info, the + sign triggers an exception, the & sign should be instead, isn'it?
Nicolas
For info, the + sign triggers an exception, the & sign should be instead, isn'it?
Nicolas
Nicolas
LC 7.1 on Windows 8.1 and on MAC OS 10.10.5 Xcode 6.4 - 7.1
LC 7.1 on Windows 8.1 and on MAC OS 10.10.5 Xcode 6.4 - 7.1
-
FourthWorld
- VIP Livecode Opensource Backer

- Posts: 10103
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Perform Basic Access Authentication
Yes. Had the code accompanied the first post it would have been caught by one of the regulars straightaway.kolia wrote:Thanks so much scrabbles, as you said, a simple missing character was the culprit.
For info, the + sign triggers an exception, the & sign should be instead, isn'it?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn