0

我需要为带有标头身份验证的 REST API 创建 kafka 源连接器,例如 curl -H "Authorization: Basic " -H "clientID: " "https:< url for source> " 。我正在使用 apache kafka,我使用了连接器类 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"

}

}

但没有希望。知道如何通过身份验证获取 REST API 数据。我的身份验证参数是 Authorization: Basic 和 Authorization: Basic 。

仅提及这两个文件都在没有身份验证的情况下使用 REST API,一旦我添加了身份验证参数,则枯萎连接器状态失败或它产生“:”无法路由。代码库/公司无效"" 主题中的消息。任何人都可以建议什么方法来解决它

4

1 回答 1

1

我将原始开发人员邮寄给 Cástor Rodríguez。根据他的解决方案,我修改了我的 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"
    }
}

在此处输入图像描述

于 2020-09-06T17:32:16.707 回答