带有身份验证头的kafka rest api源连接器

0qx6xfy6  于 2021-06-04  发布在  Kafka
关注(0)|答案(1)|浏览(419)

我需要为restapi创建kafka源连接器,使用curl-h“authorization:basic”-h“clientid:”https:“这样的头验证。我使用的是ApacheKafka,我使用的是连接器类com.github.castorm.kafka.connect.http.httpsourceconnector这里是连接器的json文件

{
    "name": "rest_data6",
    "config": {
           "key.converter":"org.apache.kafka.connect.json.JsonConverter",
           "value.converter":"org.apache.kafka.connect.json.JsonConverter",
           "key.converter.schemas.enable":"true",
           "value.converter.schemas.enable":"true",
            "connector.class": "com.github.castorm.kafka.connect.http.HttpSourceConnector",
           "tasks.max": "1",
            "http.request.headers": "Authorization: Basic <key1>",
            "http.request.headers": "clientID: <key>",
             "http.request.url": "https:<url for source ?",
           "kafka.topic": "mysqltopic2"
    }
}

我还尝试了“connector.class”:“com.tm.kafka.connect.rest.restsourceconnector”,我的joson文件如下

"name": "rest_data2",
"config": {

       "key.converter":"org.apache.kafka.connect.json.JsonConverter",
       "value.converter":"org.apache.kafka.connect.json.JsonConverter",
       "key.converter.schemas.enable":"true",
       "value.converter.schemas.enable":"true",
       "connector.class": "com.tm.kafka.connect.rest.RestSourceConnector",
       "rest.source.poll.interval.ms": "900",
       "rest.source.method": "GET",
       "rest.source.url":"URL of source ",
       "tasks.max": "1",
       "rest.source.headers": "Authorization: Basic <key> , clientId :<key2>",
"rest.source.topic.selector": "com.tm.kafka.connect.rest.selector.SimpleTopicSelector",
"rest.source.destination.topics":  "mysql1"

}

}

但没有希望。知道如何通过身份验证获取restapi数据吗。我的身份验证参数是authorization:basic和authorization:basic。
这两个文件都使用restapi而没有身份验证,一旦我添加了身份验证参数,那么wither connector的状态就是failed,或者它产生“:”cannot route。主题中的“”消息的代码库/公司无效。有人能提出解决问题的方法吗

7nbnzgx9

7nbnzgx91#

我把原始开发者发到了cástor rodr公司í盖兹。根据他的解决方案,我修改了我的json
把标题放在一个单一的形式,它的作品

{
    "name": "rest_data6",
    "config": {
           "key.converter":"org.apache.kafka.connect.json.JsonConverter",
           "value.converter":"org.apache.kafka.connect.json.JsonConverter",
           "key.converter.schemas.enable":"true",
           "value.converter.schemas.enable":"true",
            "connector.class": "com.github.castorm.kafka.connect.http.HttpSourceConnector",
           "tasks.max": "1",
            "http.request.headers": "Authorization: Basic <key1>, clientID: <key>"
             "http.request.url": "https:<url for source ?",
           "kafka.topic": "mysqltopic2"
    }
}

相关问题