Get JSON Data with NTLM authentication

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

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

Post Reply
sika05
Posts: 5
Joined: Wed Dec 26, 2018 7:53 pm

Get JSON Data with NTLM authentication

Post by sika05 » Sat Jan 05, 2019 4:40 pm

Hello,

I want to put my data JSON into an array. With the integrated library this works well
on sites without login.

Code: Select all

set the itemDelimiter to slash
   put URL "https://open library. org/api/books?bibkeys=ISBN:0385472579,LCCN:62019420&format=json" into NewsContent
   put the result into theError
   if theError is empty then
      put JSONToArray(NewsContent) into tArray
How can I use the "URL" command with NTLM Autentication. I need to add header data, but I don't find a
possibility for this?

Code: Select all

var client = new RestClient("http://srzg023. xxx. local:7048/NAV130-CH-ORIG/api/beta/companies");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "NTLM TlRMTVNTUAADAAAAGAAYAGgAAAAYABgAgAAAAAAAAABIAAAAIAAgAEgAAAAAAAAAaAAAAAAAAACYAAAABYKIogUBKAoAAAAPcwBpAGUAZwBmAHIAaQBlAGQALgBrAGEAcgBsAGUAcgAnpk+rQ3+mqQAAAAAAAAAAAAAAAAAAAACrY7GaUtg0ZZzDkkKuc8YsrwNIGR5tvhc=");
request.AddHeader("Content-Type", "application/json");
IRestResponse response = client.Execute(request);
Is this possible with live code?

Thx Siggi

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Sat Apr 08, 2006 3:06 pm
Location: Overland Park, Kansas
Contact:

Re: Get JSON Data with NTLM authentication

Post by trevordevore » Sat Jan 05, 2019 7:22 pm

You can add headers to your URL requests using the `httpheaders` property.

Code: Select all

put "Content-Type: application/json" into tHeader
put CR & "Authorization: NTLM TlRMTVNTUAADAAAAGAAYAGgAAAAYABgAgAAAAAAAAABIAAAAIAAgAEgAAAAAAAAAaAAAAAAAAACYAAAABYKIogUBKAoAAAAPcwBpAGUAZwBmAHIAaQBlAGQALgBrAGEAcgBsAGUAcgAnpk+rQ3+mqQAAAAAAAAAAAAAAAAAAAACrY7GaUtg0ZZzDkkKuc8YsrwNIGR5tvhc=" after tHeader
set the httpheaders to tHeader
That being said, NTLM authentication requires a conversation with the server in order to generate the proper token. The internet library that ships with LiveCode Community doesn't support NTLM auth out of the box. If your copy of LiveCode includes tsNet then it may support NTLM auth automatically.
Trevor DeVore
ScreenSteps - http://www.screensteps.com

Levure Application Framework: https://github.com/trevordevore/levure
LiveCode Resources for Developers: http://livecode.bluemangolearning.com

sika05
Posts: 5
Joined: Wed Dec 26, 2018 7:53 pm

Re: Get JSON Data with NTLM authentication

Post by sika05 » Sun Jan 06, 2019 7:26 pm

Hello Trevor,

thanks for the information. I first want to try if can create a application,
so I bought the community plus version.

Do you know that there is a possibility to add and use this tsnet component without buying the
expensive version?

I dont want so spend so much money only for testing, and when it not works with the programme
the money is wasted...

Thx
Siggi

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Sat Apr 08, 2006 3:06 pm
Location: Overland Park, Kansas
Contact:

Re: Get JSON Data with NTLM authentication

Post by trevordevore » Sun Jan 06, 2019 9:08 pm

I don’t know the answer to that. You could email LiveCode support and ask for details about NTLM authentication and tsNet to see if it will seamlessly work.
Trevor DeVore
ScreenSteps - http://www.screensteps.com

Levure Application Framework: https://github.com/trevordevore/levure
LiveCode Resources for Developers: http://livecode.bluemangolearning.com

Post Reply

Return to “Internet”