# Refreshing the access token when communicating with an API

**URL:** <https://discuss.elastic.co/t/refreshing-the-access-token-when-communicating-with-an-api/25384>\
**Category:** Logstash\
**Created:** [July 12, 2015, 10:52am UTC](https://discuss.elastic.co/t/refreshing-the-access-token-when-communicating-with-an-api/25384 "2015-07-12T10:52:50Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![rmarji](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rmarji/32/30138_2.png) [@rmarji](https://discuss.elastic.co/u/rmarji)\
**Post date:** [July 12, 2015, 10:52am UTC](https://discuss.elastic.co/t/refreshing-the-access-token-when-communicating-with-an-api/25384/1 "2015-07-12T10:52:50Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [July 12, 2015, 10:58am UTC](https://discuss.elastic.co/t/refreshing-the-access-token-when-communicating-with-an-api/25384/2 "2015-07-12T10:58:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rmarji](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rmarji/32/30138_2.png) [@rmarji](https://discuss.elastic.co/u/rmarji)\
**Post date:** [July 12, 2015, 11:09am UTC](https://discuss.elastic.co/t/refreshing-the-access-token-when-communicating-with-an-api/25384/3 "2015-07-12T11:09:49Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [July 12, 2015, 11:12am UTC](https://discuss.elastic.co/t/refreshing-the-access-token-when-communicating-with-an-api/25384/4 "2015-07-12T11:12:14Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![rmarji](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rmarji/32/30138_2.png) [@rmarji](https://discuss.elastic.co/u/rmarji)\
**Post date:** [July 12, 2015, 11:18am UTC](https://discuss.elastic.co/t/refreshing-the-access-token-when-communicating-with-an-api/25384/5 "2015-07-12T11:18:00Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Andrew\_Cholakian1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrew_cholakian1/32/3612_2.png) [@Andrew\_Cholakian1](https://discuss.elastic.co/u/Andrew_Cholakian1)\
**Post date:** [August 5, 2015, 4:07pm UTC](https://discuss.elastic.co/t/refreshing-the-access-token-when-communicating-with-an-api/25384/6 "2015-08-05T16:07:33Z")

</div>

@rmarji when I built HTTP Poller I put a lot of the client config and options setup in the [HTTP Client mixin](https://github.com/logstash-plugins/logstash-mixin-http_client/) . I hope that's helpful as far as building your own plugin!

---

<div class="post-metadata">

**Author:** ![Charlotte\_EGM](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/charlotte_egm/32/13503_2.png) [@Charlotte\_EGM](https://discuss.elastic.co/u/Charlotte_EGM)\
**Post date:** [June 15, 2017, 1:42pm UTC](https://discuss.elastic.co/t/refreshing-the-access-token-when-communicating-with-an-api/25384/7 "2017-06-15T13:42:22Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rmarji](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rmarji/32/30138_2.png) [@rmarji](https://discuss.elastic.co/u/rmarji)\
**Post date:** [April 18, 2018, 1:35pm UTC](https://discuss.elastic.co/t/refreshing-the-access-token-when-communicating-with-an-api/25384/8 "2018-04-18T13:35:20Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![log](https://avatars.discourse-cdn.com/v4/letter/l/e480ec/32.png) [@log](https://discuss.elastic.co/u/log)\
**Post date:** [June 11, 2019, 10:49pm UTC](https://discuss.elastic.co/t/refreshing-the-access-token-when-communicating-with-an-api/25384/9 "2019-06-11T22:49:24Z")

</div>

Following up on this issue. Any updates to report?

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [June 12, 2019, 12:23am UTC](https://discuss.elastic.co/t/refreshing-the-access-token-when-communicating-with-an-api/25384/10 "2019-06-12T00:23:53Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![San9](https://avatars.discourse-cdn.com/v4/letter/s/a9adbd/32.png) [@San9](https://discuss.elastic.co/u/San9)\
**Post date:** [December 3, 2021, 9:05am UTC](https://discuss.elastic.co/t/refreshing-the-access-token-when-communicating-with-an-api/25384/11 "2021-12-03T09:05:26Z")

</div>

Are there any changes on this issue?  
I have a similar problem.  
the problem has been going on since 2015 and I see many people care about it.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 4, 2022, 4:02am UTC](https://discuss.elastic.co/t/refreshing-the-access-token-when-communicating-with-an-api/25384/12 "2022-11-04T04:02:46Z")

</div>


