Setting up hurl correctly

Discuss about plugins that don't have a dedicated forum
Post Reply
GMKai
Posts: 140
Joined: Mon Feb 15, 2010 10:58 am

Setting up hurl correctly

Post by GMKai »

Currently I have this working command:

Code: Select all

 curl.exe  --cacert "curl-ca-bundle.crt" --cert alias.cer --key alias.key -X POST -H "Content-Type: application/x-www-form-urlencoded" -d "grant_type=client_credentials&client_id=BQFACI&client_secret=changeit&scope=Kundenmanagement"  https://api-test.atruvia.de:443/authentication/accesstoken
When transforming it to HWS, like this:

Code: Select all

@REQUIRE "hurl"

CtrlCQuit(True)
EscapeQuit(False)
@INCLUDE "hurlhelper.hws"

@DISPLAY {Hidden = True,Title="agree21-API-Tester"}

Function p_getBearerToken()
     DebugPrint("p_getBearerToken()")
     Local e = hurl.Easy()
     e:setopt_ssl_verifypeer(True)
     e:setopt_cainfo("curl-ca-bundle.crt")
     e:setopt_sslcert("alias.cer")
     e:setopt_sslkey("alias.key")
     e:setopt_default_protocol("https")
     e:setopt_post(True)
     e:setopt_postfields("grant_type=client_credentials&client_id=BQFACI&client_secret=changeit&scope=Kundenmanagement")
     e:setopt_writefunction(p_Write)
     e:setopt_headerfunction(p_Header)
     e:setopt_url("https://api-test.atruvia.de:443/authentication/accesstoken")
     DebugPrint("Getting Token")
     e:setopt_verbose(1)   
     e = p_doHurlEasyCall(e)
     e:close()
EndFunction

Function p_doHurlEasyCall(e)
     tr_data$   = ""
     tr_header$ = ""
     e:perform()
     DebugPrint("Header: "..tr_header$)
     DebugPrint("Data: "  ..tr_data$)
     Return(e)
EndFunction
 
p_getBearerToken()
It returns like this:

Code: Select all

And Action!
p_getBearerToken()
Getting Token
Error in line 42 (agree21API.hws): Problem with the local SSL certificate! (58)
What can possibly be changed to get the request working?
GMKai
Posts: 140
Joined: Mon Feb 15, 2010 10:58 am

Re: Setting up hurl correctly

Post by GMKai »

Got it working:

Code: Select all

Function p_getBearerToken()
     DebugPrint("p_getBearerToken()")
     Local e = hurl.Easy()
     e:setopt_ssl_verifypeer(True)
     e:setopt_cainfo("curl-ca-bundle.crt")
     e:setopt_sslcert("alias.cer")
     e:setopt_sslkey("alias.key")
     e:setopt_default_protocol("https")
     e:setopt_post(True)
     e:setopt_postfields("grant_type=client_credentials&client_id=BQFACI&client_secret=changeit&scope=Kundenmanagement")
     e:setopt_writefunction(p_Write)
     e:setopt_headerfunction(p_Header)
     e:setopt_url("https://api-test.atruvia.de:443/authentication/accesstoken")
     e:setopt_verbose(1)   
     e = p_doHurlEasyCall(e)
     e:close()
EndFunction

Function p_doHurlEasyCall(e)
     tr_data$   = ""
     tr_header$ = ""
     DebugPrint("Getting Token")
     e:perform()
     DebugPrint("Header: "..tr_header$)
     DebugPrint("Data: "  ..tr_data$)
     Return(e)
EndFunction
At least on MorphOS I get my token.
I would love to have this running under Windows.
Any comments regarding Schannel and maybe a proxy?
GMKai
Posts: 140
Joined: Mon Feb 15, 2010 10:58 am

Re: Setting up hurl correctly

Post by GMKai »

Code: Select all

Execute("token_request.bat", "",{hide="True"})
works in a way to execute the request, but i still get to see an cmd-window?
In what way do I have to create the hide-parm?
User avatar
airsoftsoftwair
Posts: 5450
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Setting up hurl correctly

Post by airsoftsoftwair »

GMKai wrote: Fri Mar 15, 2024 8:25 am works in a way to execute the request, but i still get to see an cmd-window?
In what way do I have to create the hide-parm?
See here: https://forums.hollywood-mal.com/viewtopic.php?t=3679

:)
GMKai
Posts: 140
Joined: Mon Feb 15, 2010 10:58 am

Re: Setting up hurl correctly

Post by GMKai »

https://www.hollywood-mal.com/docs/html ... cute_.html

The documentation of the optional table seems to be misssing the hide-option?

I tweeked the call a little bit, still the black window pops up.
What else do I have to set in the .bat to have it working, or do I have to live with the popup?
User avatar
airsoftsoftwair
Posts: 5450
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Setting up hurl correctly

Post by airsoftsoftwair »

GMKai wrote: Tue Mar 19, 2024 8:19 am The documentation of the optional table seems to be misssing the hide-option?
It's not supported in Hollywood 10.0, it was implemented after 10.0 was released.
Post Reply