Thx Petr
I will keep trying a bit more to build the Digest Auth.
I'm now facing something more related to Javascript.
I get a response in JSON format (it's not XML as I wrote, if I understand correctly now):
{"Transfer-Encoding":"chunked","Server":"nginx","WWW-Authenticate":"Digest qop=\"auth\", realm=\"apiservername.com\", nonce=\"W5Ro76MktlUNvQVVnTsxtixinlUryqEU_1665320280\"","Connection":"keep-alive","Date":"Sun, 09 Oct 2022 12:58:00 GMT"}
I'm able to "extract" or parse this JSON and I can get the values of "Server" or "Connection"
but I cannot get the "WWW-Authenticate" nor "Transfer-Encoding" values
and I suspect that it is caused by the dash "-" in those field names.
Is there a simple syntax change to correct my script ?
I write:
//Script herevar authget ;var server ;var encoding;authget = JSON.parse(responseheader);server = authget.Server;encoding = authget.Connection;but trying to add
authentication = authget.WWW-Authenticate,and error:
2022/10/25 18:36:00 - Modified JavaScript value.0 - ERROR (version 9.3.0.0-428, build 9.3.0.0-428 from 2022-04-12 04.56.25 by buildguy) : Unexpected error
2022/10/25 18:36:00 - Modified JavaScript value.0 - ERROR (version 9.3.0.0-428, build 9.3.0.0-428 from 2022-04-12 04.56.25 by buildguy) : org.pentaho.di.core.exception.KettleValueException:
2022/10/25 18:36:00 - Modified JavaScript value.0 - Javascript error:
2022/10/25 18:36:00 - Modified JavaScript value.0 - ReferenceError:
"Authenticate" is not defined. (script#12)
thx
------------------------------
Marc M
Chief Information Officer
mkmr
------------------------------
Original Message:
Sent: 10-20-2022 11:25
From: Petr Prochazka
Subject: REST digest auth How-to
Hi Marc,
digest authentication is not so simple, flow is for ex. here: https://www.w3.org/Protocols/HTTP/Issues/digest-authentication.html
IMHO better is use any Java HTTP client in JS step and download directly to file or field in stream. On classpath are available classes of httpclient.jar for ex.
------------------------------
Petr Prochazka
Systems Engineer
P.V.A. systems s.r.o.
Original Message:
Sent: 10-09-2022 09:21
From: Marc M
Subject: REST digest auth How-to
Hi
I'm having a hard time trying to set up digest Auth to get data from an API call. I have read and tried every advice found by google :(
Via a web browser, it's enough to open https://apiservername/user?groupName=group to get a signin popup for username/password. And this gives me an XML file to save locally.
With Pentaho Spoon, I currently have set these steps up:
- generate rows (1 row where I may define useful values like URL, user, password...)
- modify javaScript value (not really used but ready )
- Rest client (POST to try and get a token...)
- modify javaScript value (this is where I expect to be able to extract a token from the header returned by the previous step)
- Rest client (GET where I expect to ask and receive the XML file, result of my request)
what I get at step3 is some kind of table in the header as result of the POST:
{"Transfer-Encoding":"chunked","Server":"nginx","WWW-Authenticate":"Digest qop=\"auth\", realm=\"apiservername.com\", nonce=\"W5Ro76MktlUNvQVVnTsxtixinlUryqEU_1665320280\"","Connection":"keep-alive","Date":"Sun, 09 Oct 2022 12:58:00 GMT"}
Can someone help me find the next steps ?
How do I extract and use these header data ?
I think I should be looking for some "token" but still have not found where to find it.
Please any advice is welcome.
Thx
Marc