# HubSpot timeline API in background with OAuth token

**URL:** <https://community.hubspot.com/t/hubspot-timeline-api-in-background-with-oauth-token/11655>\
**Category:** APIs & Integrations\
**Tags:** oauth\
**Created:** [October 9, 2018, 6:19am UTC](https://community.hubspot.com/t/hubspot-timeline-api-in-background-with-oauth-token/11655 "2018-10-09T06:19:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [October 9, 2018, 6:19am UTC](https://community.hubspot.com/t/hubspot-timeline-api-in-background-with-oauth-token/11655/1 "2018-10-09T06:19:25Z")

</div>

Hi,

How can I integrate Timeline API into my project where any action made by user will create a timeline in background job?

I read that it requires OAuth token, but if my website is hosted then how much time OAuth token will be valid?

Does that means I need to login ONLY ONCE to obtain token after that from background I can refresh token?

---

<div class="post-metadata">

**Author:** ![IsaacTakushi](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/isaactakushi/32/70387_2.png) [@IsaacTakushi](https://community.hubspot.com/u/IsaacTakushi)\
**Post date:** [October 9, 2018, 1:09pm UTC](https://community.hubspot.com/t/hubspot-timeline-api-in-background-with-oauth-token/11655/2 "2018-10-09T13:09:15Z")

</div>

Hi [@yogen](https://community.hubspot.com/u/yogen),

As outlined in [this article](https://developers.hubspot.com/docs/methods/oauth2/get-access-and-refresh-tokens), OAuth tokens expire after **6 hours**. You can then use the refresh token to get a new access token which will last another 6 hours. It is certainly possible to set up automation to repeatedly refresh your integration’s access token every 6 hours. The `refresh_token` you receive when initiating the OAuth connection does _not_ expire, so you can keep using it to refresh the `access_token`.

Do you have any other specific questions after reviewing the [Timeline API overview documentation](https://developers.hubspot.com/docs/methods/timeline/timeline-overview)? I also found [this similar topic](https://integrate.hubspot.com/t/keeping-oauth2-access-tokens-refreshed/3113) relating to authenticating the Timeline API.

---

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [October 9, 2018, 1:45pm UTC](https://community.hubspot.com/t/hubspot-timeline-api-in-background-with-oauth-token/11655/3 "2018-10-09T13:45:36Z")

</div>

[@Isaac\_Takushi](https://community.hubspot.com/u/isaac_takushi) Thanks for quick reply.

What I understood is, After hosting my app, I need to LOGIN Only once to get initial token and refresh token.

After that, I can use refresh\_token in background job to get updated token every time without being worried about expiration.

---

<div class="post-metadata">

**Author:** ![IsaacTakushi](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/isaactakushi/32/70387_2.png) [@IsaacTakushi](https://community.hubspot.com/u/IsaacTakushi)\
**Post date:** [October 9, 2018, 1:47pm UTC](https://community.hubspot.com/t/hubspot-timeline-api-in-background-with-oauth-token/11655/4 "2018-10-09T13:47:14Z")

</div>

That’s correct, [@yogen](https://community.hubspot.com/u/yogen)! Once you get the `refresh_token`, you can use it whenever you need a new `access_token`. The `refresh_token` does not expire.
