Hello
I want to read messages from an HTTP API which requires an access token for authentication.
In documentation, I found two ways to handle authentication:
- basic auth with username and password: this can't be used in my case beacause I need to inject an access token in headers instead of username/password
- oauth: I tried the following configuration but it is not working
filebeat.inputs:
- type: httpjson
config_version: 2
auth.oauth2:
user: "user"
password: "password!"
grant_type: "password"
token_url: "https://<domain>/api/auth"
request.url: https://<domain>/api/xxx
request.method: GET
interval: 30s
Error:
{"log.level":"error","@timestamp":"2024-07-23T10:54:31.155Z","log.logger":"input.httpjson-stateless","log.origin":{"function":"github.com/elastic/beats/v7/filebeat/input/v2/compat.(*runner).Start.func1","file.name":"compat/compat.go","file.line":132},"message":"Input 'httpjson-stateless' failed with: oauth2 client: error loading credentials using user and password: oauth2: cannot fetch token: 400 Bad Request\nResponse: {\"error\":\"invalid request body\"}","service.name":"filebeat","id":"44BE8C40AEF18D3B","ecs.version":"1.6.0"}
I just need a way to retreive the access token using user/password and then inject it in the request's headers.
Tried this both version 8.14.3 and 7.17 and none of them is working
I have another question, is there an input that allows HEAD http requests ? httpjson and http_endpoint do not support it.
Thank you