6 Replies Latest reply on Oct 12, 2014 8:43 PM by jbpm 6

    how to assign Authentication token to REST Service Task

    jbpm 6 Newbie

      I am calling a REST service from jbpm using the REST service task but I don't know how to specify the Authorization Token (assignment picture attached). Does anyone know how to do this? Your help will be much appreciated.

       

      This is the curl command:

      curl -H "Authorization: Token 76f6fa094dec43f244bf1e1f45548eca123456c1" https://abc.com/api/customers/ -k

        • 1. Re: how to assign Authentication token to REST Service Task
          Maciej Swiderski Master

          jbpm REST work item handler accepts only BASIC and FORM based authentication so you need to configure handler accordingly. I am afraid there is no support for tokens.

           

          HTH

          • 2. Re: how to assign Authentication token to REST Service Task
            jbpm 6 Newbie

            Thanks Maciej,

             

            I created a custom REST WorkItemahandler. Then

             

            (1) copy the jar to [jbpm]/standalone/deployments/business-central.war/WEB-INF/lib

            (2) add "CustomREST": new com.developer.CustomRestWorkItemHandler() to [jbpm]/standalone/deployments/business-central.war/WEB-INF/classes/META-INFCustomWorkItemHandlers.conf

            (3) create a new project in workbench

            (4) navigate to src/main/resources/META-INF/ and upload CustomWorkItem.wid file

                 

                import org.drools.core.process.core.datatype.impl.type.StringDataType;

                 import org.drools.core.process.core.datatype.impl.type.ObjectDataType;

                 import org.drools.core.process.core.datatype.impl.type.BooleanDataType;

                 [

                        [

                          "name" : "CustomREST",

                          "parameters" : [

                              "Url" : new StringDataType(),

                              "Method" : new StringDataType(),

                              "Body" : new StringDataType(),

                              "ConnectTimeout" : new StringDataType(),

                              "ReadTimeout" : new StringDataType(),

                              "Username" : new StringDataType(),

                              "Password" : new StringDataType(),

                              "ContentType" : new StringDataType(),

                              "Authorization" : new StringDataType(),

                              "IgnoreSSL" : new BooleanDataType()

                          ],

                          "results" : [

                              "Result" : new ObjectDataType(),

                          ],

                          "displayName" : "CustomREST",

                          "icon" : "icons/restlogo.png"

                        ]

                 ]

             

            (5) create a new "Business Process".


            From the process designer in the palette on the left in "Service Tasks" the activity should appear CustomREST, but for some reason I can't see this icon. Can you please advise if I missed out any configuration? Thanks.

            • 3. Re: how to assign Authentication token to REST Service Task
              Maciej Swiderski Master

              it could be that the icon is not found and thus not showing on palette. Could you try to use the default icon as it used by default here.

               

              HTH

              • 4. Re: how to assign Authentication token to REST Service Task
                Karl Laird Newbie

                Surely there should be a way to set HTTP Headers generally? 

                It's pretty common for things to be needed in the header as well or instead of the JSON Body.

                • 5. Re: how to assign Authentication token to REST Service Task
                  Maciej Swiderski Master

                  it does allow to set some headers like content type etc but does not support any header to be set. If you see this as valuable addition feel free to drop feature request jira for it.

                   

                  HTH

                  • 6. Re: how to assign Authentication token to REST Service Task
                    jbpm 6 Newbie

                    Thanks Maciej,

                     

                    I have resolved this issue. I loaded the CustomWorkItem.wid file to the wrong directory. It should be loaded into src/main/resources instead of src/main/resources/META-INF