Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

basic authentication 1

Status
Not open for further replies.

Olaf Doschke

Programmer
Joined
Oct 13, 2004
Messages
14,847
Location
DE
I recently tried an API, which required basic auth (safely via https), but didn't work with the user/password parameters of the open method of MSXML2.XMLHTTP.

Wikipedia to the rescue, look at
You get the description of what header to set client side:

Code:
o = CreateObject("msxml2.xmlhttp")
o.open("GET","[URL unfurl="true"]https://apiurl...")[/URL]

[b]lcBasicAuth = "Basic " + Chrtran(Strconv(cUser+":"+cPassword,13),"=","")
o.setRequestHeader("Authorization",lcBasicAuth)[/b]

o.send()
...

There's one tricky hurdle:
[tt]Strconv("Aladdin:OpenSesame",13)[/tt] nicely turns to the sample base64 encoding QWxhZGRpbjpPcGVuU2VzYW1l, but that's generally not enough. When the [tt]user:password[/tt] string length is not a multiple of 3. the "=" VFP correctly uses to pad the base64 representation is not valid in the http request header, thus the removal of "=".

In respect of the user/password parameters of the open method I don't find how they are really used for which type of authentication, maybe it's also just a limitation of the one API I used, which was the desk.com API of the salesforce help desk.

Bye, Olaf.
 
You should try NetHelpDesk help desk software. Much better than desk.com
 
You should try NetHelpDesk help desk software. Much better than desk.com

I hope you won't mind me asking, but have you got any connection with that product? Do you work for the vendor? I was just wondering.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top