Uploaded image for project: 'Red Hat Fuse'
  1. Red Hat Fuse
  2. ENTESB-5974

Unable to set Authorization header in camel-http4 component

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Do
    • Icon: Major Major
    • fuse-7.0
    • jboss-fuse-6.2.1
    • Camel
    • None
    • DEV

    • Hide

      <camelContext xmlns="http://camel.apache.org/schema/spring">
      <route>
      <from uri="timer://foo?fixedRate=true&period=60000"/>
      <log message="timer has begun"/>
      <setHeader headerName="CamelHttpMethod">
      <constant>POST</constant>
      </setHeader>
      <setHeader headerName="Authorization">
      <constant>
      Bearer <tokenhere>==
      </constant>
      <setBody>
      <constant>

      { "sinceTime": 1415667600000, "untilTime": 1415671200000}

      </constant>
      </setBody>
      <to uri="http4://myhost.com/api/v3.1/listening/query/stream"/>
      </route>
      </camelContext>

      Show
      <camelContext xmlns="http://camel.apache.org/schema/spring"> <route> <from uri="timer://foo?fixedRate=true&period=60000"/> <log message="timer has begun"/> <setHeader headerName="CamelHttpMethod"> <constant>POST</constant> </setHeader> <setHeader headerName="Authorization"> <constant> Bearer <tokenhere>== </constant> <setBody> <constant> { "sinceTime": 1415667600000, "untilTime": 1415671200000} </constant> </setBody> <to uri="http4://myhost.com/api/v3.1/listening/query/stream"/> </route> </camelContext>

      Authorization header is missing as part of default headers for camel-http4 so I tried to assign Authorization header to my exchange as below:

      <camelContext xmlns="http://camel.apache.org/schema/spring">
      <route>
      <from uri="timer://foo?fixedRate=true&period=60000"/>
      <log message="timer has begun"/>
      <setHeader headerName="CamelHttpMethod">
      <constant>POST</constant>
      </setHeader>
      <setHeader headerName="Authorization">
      <constant>
      Bearer <tokenhere>==
      </constant>
      <setBody>
      <constant>

      { "sinceTime": 1415667600000, "untilTime": 1415671200000}

      </constant>
      </setBody>
      <to uri="http4://myhost.com/api/v3.1/listening/query/stream"/>
      </route>
      </camelContext>

      The header is not getting set in the request header. One of our potential email providers uses a bearer authentication token. This means they are using an Oauth machinery for credential verification. In the curl format they use something like: curl -X "POST" "https://vendor_url" -H "Authorization: Bearer YOUR_API_KEY" -H "Content-Type: application/json" -d "[YOUR DATA HERE]". I don’t see anything in the camel-http4 components that exposes the additional header entry for Authorization like Content-Type.

      Looking at class org.apache.camel.component.http4.HttpProducer, I could not find the logic that was assigning the arbitrary headers to the request, and looking at the requests in Fiddler did not display such headers. I need help on how I can use camel-http4 for this without having to go to HttpClient code base.

        1. Unknown (image_png)
          1.0 kB
        2. Unknown (image_png)
          0.3 kB
        3. Unknown (image_png)
          1 kB
        4. Unknown (image_png)
          3 kB

              janstey@redhat.com Jonathan Anstey
              ooteniya@redhat.com Olumide Oteniya (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: