Question

Token Bearer recovery problem by script

  • 6 March 2024
  • 1 reply
  • 26 views

Badge

Hello everyone ,

I am trying to retrieve a Bearer Token with the GET Bearer Token script on ARC script connector :

 

Below is my script :


<arc:set attr="http.URL"      value="https://prodautok.authentication.eu10.hana.ondemand.com/oauth/token?grant_type=client_credentials&token_format=jwt" />
<arc:set attr="http.postdata" value='{"password":"XXXXXXX=","username":"sb-21f210cb-9a40-44f8-a78f-c23d13ceec27!b185659|it-rt-prodautok!b117912"}' />
<arc:call op="httpPost" in="http" out="response">
  <!-- Pass in the json response that contains the token to jsonOpen. -->
  <arc:set attr="token.text" value="[http:content]" />
  <arc:call op="jsonOpen" in="token" out="handle">
    <!-- Call jsonDOMGet with the handle that was obtained from jsonOpen. -->
    <arc:set attr="json.handle"    value="[handle.handle]" />
    <arc:set attr="json.map:token" value="/json/access_token" />
    <arc:call op="jsonDOMGet" in="json" out="result" >
      <!-- Set the token as a "token" header on the output message. -->
      <arc:set attr="output.header:token" value="[result.token]" />
    </arc:call>
  </arc:call>
</arc:call>
<!-- Push out the original input file. -->
<arc:set attr="output.filepath" value="[filepath]" />
<arc:push item="output" />

 

1-When I send a message, I get an error:

401 unauthorized.

I checked URL and password and they are good (I tested on POSTMAN with)

 

2-Does anyone have a solution or has anyone had this problem before?

 

Best regards


1 reply

Userlevel 1

Hi Alex,

 

Could you please verify the username and password entered? They appear to be misplaced here; I assume.

<arc:set attr="http.postdata" value='{"password":"XXXXXXX=","username":"sb-21f210cb-9a40-44f8-a78f-c23d13ceec27!b185659|it-rt-prodautok!b117912"}' />

 

As I side note, Please ensure to select the appropriate category from the dropdown whenever you ask a question. This helps to prevent your question from going unanswered for an extended period.

 

Always reach out to arcsupport@cdata.com for further assistance.

 

Reply