Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add HTTP Connector Example #323

Closed
kferrone opened this issue Sep 16, 2021 · 4 comments
Closed

Add HTTP Connector Example #323

kferrone opened this issue Sep 16, 2021 · 4 comments

Comments

@kferrone
Copy link

I'm having a lot of trouble trying to figure out how to use the HTTP connector with an endpoint which needs a bearer token in the Authorization header. Please add some http examples using auth tokens

@oscerd
Copy link
Contributor

oscerd commented Sep 16, 2021

You just need to send an header together with the payload to the sink connector. This header should be named "CamelHeader.Authorization" with the bearer token as value.

@kferrone
Copy link
Author

kferrone commented Sep 16, 2021

Ok, so I am using the unofficial strimzi-cli here for local testing and Strimzi is running in kubernetes.

I made a file called producer.properties with the following on my local machine:

CamelHeader.Authorization=Bearer 123token456

Then I run this command to create a producer from the cli

kfk console-producer --topic my-topic -c my-cluster -n default --producer.config producer.properties

Then I paste the following:

{"message": "foo"}

I see my consumers do get the message including the connector.
However I am still getting 403 back from the endpoint from within the sink connector.
Did I even do what you are saying?

How to debug the actual request getting made to the endpoint? I want to see the headers, body and all.

I also get this warning when I open the producer terminal:

WARN The configuration 'CamelHeader.Authorization' was supplied but isn't a known config. (org.apache.kafka.clients.producer.ProducerConfig)

@oscerd
Copy link
Contributor

oscerd commented Sep 17, 2021

I would use Kafkacat and add a

-H CamelHeader.Authorization="Bearer 123token456"

@kferrone
Copy link
Author

Oh my hero! Kafkacat worked well for me. It looks like there is a bug in the Strimzi CLI. I was pulling my hair out. I'll let them know something isn't working right. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants