# Automate refresh token to gain access token for each API request in Python

**URL:** <https://devforum.zoom.us/t/automate-refresh-token-to-gain-access-token-for-each-api-request-in-python/68034>\
**Category:** API and Webhooks\
**Created:** [April 25, 2022, 5:18am UTC](https://devforum.zoom.us/t/automate-refresh-token-to-gain-access-token-for-each-api-request-in-python/68034 "2022-04-25T05:18:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nazura97](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/nazura97/32/37175_2.png) [@nazura97](https://devforum.zoom.us/u/nazura97)\
**Post date:** [April 25, 2022, 5:18am UTC](https://devforum.zoom.us/t/automate-refresh-token-to-gain-access-token-for-each-api-request-in-python/68034/1 "2022-04-25T05:18:43Z")

</div>

**Description**  
I am trying to extract data on inactive/active users for my organization’s Zoom subscription and I’m trying to have this done using Python that will be triggered everyday. I am using the oauth method so the python code will have to generate new access token using the refresh token gotten from the first access token request that made use of the authorization code from the redirect url of the oauth app.

This code should be triggered automatically to get access token -\>request for data-\>store them into SQL database. My problem now is that the refresh token for the oauth renew after every use. Is there any other simpler method to do this? My only thinking now is that after every access token request I need to store the new refresh token in a database and access it again for each new access token request.

Appreciate if anyone can suggest a better way to do this.

**Which App Type (OAuth / Chatbot / JWT / Webhook)?**  
OAuth

**Which Endpoint/s?**  
[https://api.zoom.us/v2/report/users](https://api.zoom.us/v2/report/users)

---

<div class="post-metadata">

**Author:** ![donte.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/donte.zoom/32/24412_2.png) [@donte.zoom](https://devforum.zoom.us/u/donte.zoom)\
**Post date:** [May 4, 2022, 5:06am UTC](https://devforum.zoom.us/t/automate-refresh-token-to-gain-access-token-for-each-api-request-in-python/68034/2 "2022-05-04T05:06:53Z")

</div>

Hi, @nazura97,

Thank you for posting in the Developer Forum – great question! You’re correct, you will need to store the latest refresh token in a database and access it for each new access token request. As you noted, the refresh token will become invalidated once a new access token to generate. For this reason, you want to make sure that you are using the latest refresh token to generate a new access token.

Regards,  
Donte

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/6/1/614bdd549b610bbaa46ff934617683a02bdaa03c.png) [@system](https://devforum.zoom.us/u/system)\
**Post date:** [June 3, 2022, 3:07pm UTC](https://devforum.zoom.us/t/automate-refresh-token-to-gain-access-token-for-each-api-request-in-python/68034/3 "2022-06-03T15:07:27Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
