Page 1 of 1

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

Posted: Sat Oct 26, 2024 9:14 pm
by andyh1234
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

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

Posted: Sat Oct 26, 2024 10:14 pm
by jmburnod
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

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

Posted: Sun Oct 27, 2024 1:31 pm
by andyh1234
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