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?

    In my test, before the Rest Client step I put a Generate Rows with 2 fields:

    URL: my endpopint

    Authorization: with the value Bearer {my_token}

    In the job properties I also create a parameter called Authorization with the same value

    Now, in the REST Client step, in the Header tab in the filed I selected Authorization and in the Name I  set ${Authorization}.

    After that, I executed he transformations but the answer was that the Authorization is incorrect.

    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.

    So, how can I do it in Pentaho Data Integration?

    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
    ------------------------------



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

    Posted 21 days ago
    Hey Igor,
     
    You're right, working with authorization in Pentaho Data Integration can be a bit tricky, but you're absolutely on the right track. Instead of working with authorization directly on the Header tab, try a different approach.
     
    In the REST Client step, go to the 'HTTP Options' tab. You'll find a field called 'HTTP Header Name', set that to 'Authorization', and in the 'HTTP Header Value', put 'Bearer ${Authorization}'. This way, you're explicitly telling Pentaho to include 'Authorization' in the header with the Bearer token.
     
    Also, ensure that your 'Authorization' parameter is being passed correctly from the Generate Rows step to the REST Client step. A bit of information about such technologies can be found here: https://andersenlab.com/blueprint/a-digital-transformation-strategy-guide
     
    I've faced a similar challenge before, and this setup worked for me. Sometimes tools like Postman abstract these details, but Pentaho gives you more control.
     
    Give it a shot, and let me know.



    ------------------------------
    Valeri Bakop
    Others
    Freelance
    ------------------------------