Pentaho

 View Only
  • 1.  Rest Client – How to setup an Authorization Bearer in the REST Client?

    Posted 02-14-2023 14:37

    Hi Guys, I need to consume an API that in the header I need to pass the Authorization that is a bearer? How can I do that?<o:p></o:p>

    In my test, before the Rest Client step I put a Generate Rows with 2 fields:<o:p></o:p>

    URL: my endpopint<o:p></o:p>

    Authorization: with the value Bearer {my_token}<o:p></o:p>

    In the job properties I also create a parameter called Authorization with the same value<o:p></o:p>

    Now, in the REST Client step, in the Header tab in the filed I selected Authorization and in the Name I  set ${Authorization}. <o:p></o:p>

    After that, I executed he transformations but the answer was that the Authorization is incorrect.<o:p></o:p>

    Just to check if my token was valid, I made test using postman, and it works properly. The difference is that in the postman there is a tab that I can choose the type, in my case Bearer Token and then I put the token. I the header I didn't need to put nothing.<o:p></o:p>

    So, how can I do it in Pentaho Data Integration?<o:p></o:p>

    Regards, Igor Martins



    ------------------------------
    Igor Martins
    Director of Sales
    Particular
    ------------------------------


  • 2.  RE: Rest Client – How to setup an Authorization Bearer in the REST Client?

    Posted 02-15-2023 09:06

    Hello Igor,

      I did this with two REST client steps.

    In the first REST client step I authenticate via the login endpoint and retrieve the Authentication token by parsing the JSON output.

    Then form the login API response I isolate the authentication token and configure the subsequent REST client Headers tab with "Authorization" Name and as Field I choose the stream variable containing the token retrieved by the first REST client.

    If you isolate the authentication token retrieval in another transformation you could implement also the logic for the automatic reissue of expired tokens due to timeouts.

    Best regards,



    ------------------------------
    Antonio Petrella
    Data Service Manager
    UNOG
    ------------------------------



  • 3.  RE: Rest Client – How to setup an Authorization Bearer in the REST Client?

    Posted 02-16-2023 02:57

    Hi Igor

    may be this can help: https://community.hitachivantara.com/discussion/rest-digest-auth-how-to 

    I stored the username and password hardcoded in the steps while struggling with the token and did not changed after as it was working, but I think it should work as well.

    Marc



    ------------------------------
    Marc M
    Chief Information Officer
    mkmr
    ------------------------------