Refreshing the access token when communicating with an API

I'm trying to use Http_poller input plugin, to get results from an API, it works fine while the access token is valid, however its only valid for one hour, I want to be able to refresh the access token with the refresh token that I already have, using a post request.

So I'm not sure how to make this post request for the refresh. and how to change the URL to have the new access token.

Might be tough with the current plugin, as it's pretty basic and doesn't take this sort of use into account.

it doesn't have to be this plugin, I'm thinking I could use conditionals and other input plugins to accomplish the refresh every hour. however not sure which one can let me do post and how to store the value.

Thing is LS has no concept of time passed, it doesn't really track things like cron (for eg). Plus you'd have to restart LS every time you changed the config (at least until 2.X release).

aha, so it would make more sense to do the refresh outside of logstash and restart logstash with new config.

I think it also can be accomplished by building a new plugin. I will try my luck with that, although I'm not familiar with Ruby.

@rmarji when I built HTTP Poller I put a lot of the client config and options setup in the HTTP Client mixin . I hope that's helpful as far as building your own plugin!

is there any improvement on this issue ? I have exactly the same issue and need to refresh the access token with a POST request

1 Like

not really! have you found a way of resolving this?

Following up on this issue. Any updates to report?

Is there any documentation of what a mixin is? I see them all the time in scanning github, so I know they are encapsulating something. Did you folks document that?