Get text from a web page that requires a username and password

Bringing the internet highway into your project? Building FTP, HTTP, email, chat or other client solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
andyh1234
Posts: 476
Joined: Mon Aug 13, 2007 4:44 pm
Contact:

Get text from a web page that requires a username and password

Post by andyh1234 » Sat Oct 26, 2024 9:14 pm

Im trying to get some data from a website that uses a username and password

the URL

https://username:password@www.sampleurl ... /accounts/

works fine in a web browser, but the code

Code: Select all

put "https://username:password@www.sampleurl.com/v1/accounts/" into tUrl
put URL tURL into tResult
answer tResult
returns nothing. Is there another way to do this with Livecode as it seems to get thrown by the username and password into the URL

Thanks

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Get text from a web page that requires a username and password

Post by jmburnod » Sat Oct 26, 2024 10:14 pm

Hi,
You may try this.

Code: Select all

put "https://username:password@www.sampleurl.com/v1/accounts/" into tUrl
put url("file:" & tUrl) into tResult
answer tResult
Best regards
Jean-Marc
https://alternatic.ch

andyh1234
Posts: 476
Joined: Mon Aug 13, 2007 4:44 pm
Contact:

Re: Get text from a web page that requires a username and password

Post by andyh1234 » Sun Oct 27, 2024 1:31 pm

I have found the answer, using httpheaders

Code: Select all


put base64Encode(username) into username
put base64Encode(password) into apikey

put "Authorization: Basic" && username & ":" & password & cr into tHeader
set the httpHeaders to tHeader
put "https://www.sampleurl.com/v1/accounts/" into tUrl
put url("file:" & tUrl) into tResult
answer tResult


Post Reply