# Occasional error when refreshing access / zak tokens

**URL:** <https://devforum.zoom.us/t/occasional-error-when-refreshing-access-zak-tokens/21377>\
**Category:** API and Webhooks\
**Created:** [June 15, 2020, 1:57pm UTC](https://devforum.zoom.us/t/occasional-error-when-refreshing-access-zak-tokens/21377 "2020-06-15T13:57:17Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![naved.khan](https://avatars.discourse-cdn.com/v4/letter/n/f0a364/32.png) [@naved.khan](https://devforum.zoom.us/u/naved.khan)\
**Post date:** [June 15, 2020, 1:57pm UTC](https://devforum.zoom.us/t/occasional-error-when-refreshing-access-zak-tokens/21377/1 "2020-06-15T13:57:17Z")

</div>

**Description**  
We run background jobs to keep our user’s tokens and zak tokens refreshed and valid. Occasionally, our jobs will return {“reason”=\>“Invalid request : token created error: Save Access token into Database error”, “error”=\>“invalid\_request”}. Subsequent retries might work, but we end up with expired tokens sometimes because of this error.

**Error**  
{“reason”=\>“Invalid request : token created error: Save Access token into Database error”, “error”=\>“invalid\_request”}

**Which App Type (OAuth / Chatbot / JWT / Webhook)?**  
Oauth, both account and user levels.

**Which Endpoint/s?**  
/token/

**How To Reproduce (If applicable)**  
Steps to reproduce the behavior:

1. Attempt to refresh token due to expire in a few minutes
2. {“reason”=\>“Invalid request : token created error: Save Access token into Database error”, “error”=\>“invalid\_request”}

**Screenshots (If applicable)**  
None

**Additional context**  
None

---

<div class="post-metadata">

**Author:** ![tommy](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/tommy/32/72769_2.png) [@tommy](https://devforum.zoom.us/u/tommy)\
**Post date:** [June 18, 2020, 4:33am UTC](https://devforum.zoom.us/t/occasional-error-when-refreshing-access-zak-tokens/21377/2 "2020-06-18T04:33:46Z")

</div>

Hey @naved.khan,

That is strange. Can you please email this error, and your request url, query params, and headers to [developersupport@zoom.us](mailto:developersupport@zoom.us) so we can take a closer look?

Have you considered refreshing the tokens on user action, for example, once user clicks a create meeting button, check the database to see if the token is expired via the expires\_in value, and then if expired, refresh the token, save the new tokens, and then call the API?

Thanks,  
Tommy

---

<div class="post-metadata">

**Author:** ![naved.khan](https://avatars.discourse-cdn.com/v4/letter/n/f0a364/32.png) [@naved.khan](https://devforum.zoom.us/u/naved.khan)\
**Post date:** [June 18, 2020, 7:37am UTC](https://devforum.zoom.us/t/occasional-error-when-refreshing-access-zak-tokens/21377/3 "2020-06-18T07:37:06Z")

</div>

Hey,

Here is the request we’re making in Ruby code.

```auto
        response = HTTParty.post(
            "https://zoom.us/oauth/token?grant_type=refresh_token&refresh_token=#{zoom_account.refresh_token}",
            basic_auth: {
                username: client_id,
                password: client_secret
            }
        )

```

The response to this request is

```auto
{“reason”=>“Invalid request : token created error: Save Access token into Database error”, “error”=>“invalid_request”}

```

This error is not consistent, we see it frequently, but not with every request.

---

<div class="post-metadata">

**Author:** ![tommy](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/tommy/32/72769_2.png) [@tommy](https://devforum.zoom.us/u/tommy)\
**Post date:** [June 23, 2020, 5:24pm UTC](https://devforum.zoom.us/t/occasional-error-when-refreshing-access-zak-tokens/21377/4 "2020-06-23T17:24:24Z")

</div>

Hey @naved.khan,

Your ruby code looks correct. I am guessing this is happening when you are batch calling the Zoom refresh token API.

Have you considered refreshing the tokens on user action, for example, once user clicks a create meeting button, check the database to see if the token is expired via the expires\_in value, and then if expired, refresh the token, save the new tokens, and then call the API?

Thanks,  
Tommy

---

<div class="post-metadata">

**Author:** ![sgani](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/sgani/32/4519_2.png) [@sgani](https://devforum.zoom.us/u/sgani)\
**Post date:** [June 24, 2020, 3:21pm UTC](https://devforum.zoom.us/t/occasional-error-when-refreshing-access-zak-tokens/21377/5 "2020-06-24T15:21:02Z")

</div>

Hi –

I’d like to also chime and say that we’ve seen this error message (`Invalid request : token created error: Save Access token into Database error`) twice in the last 24 hours when trying to renew a token.

TY.

---

<div class="post-metadata">

**Author:** ![tommy](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/tommy/32/72769_2.png) [@tommy](https://devforum.zoom.us/u/tommy)\
**Post date:** [June 25, 2020, 7:49pm UTC](https://devforum.zoom.us/t/occasional-error-when-refreshing-access-zak-tokens/21377/6 "2020-06-25T19:49:23Z")

</div>

Thanks for letting us know @sgani!

Our engineering team is looking into this. I will provide updates here. (ZOOM-172624)

-Tommy

---

<div class="post-metadata">

**Author:** ![mac](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/mac/32/3311_2.png) [@mac](https://devforum.zoom.us/u/mac)\
**Post date:** [July 6, 2020, 1:14pm UTC](https://devforum.zoom.us/t/occasional-error-when-refreshing-access-zak-tokens/21377/7 "2020-07-06T13:14:11Z")

</div>

> [@tommy](#):
>
> ZOOM-172624

Hey Tommy,  
I also just noticed this error on our system, what is the link to the ZOOM-172624? Would love to keep an eye on this.

---

<div class="post-metadata">

**Author:** ![tommy](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/tommy/32/72769_2.png) [@tommy](https://devforum.zoom.us/u/tommy)\
**Post date:** [July 6, 2020, 4:22pm UTC](https://devforum.zoom.us/t/occasional-error-when-refreshing-access-zak-tokens/21377/8 "2020-07-06T16:22:28Z")

</div>

Hey @sgani, @mac, @naved.khan,

Our engineers said that this error is thrown when refreshing with the same refresh token multiple times in a very short time. In this cases only one request (the first one) will return the 200 response with the new access token and refresh token, the other requests will return the error.

Thanks,  
Tommy

---

<div class="post-metadata">

**Author:** ![mac](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/mac/32/3311_2.png) [@mac](https://devforum.zoom.us/u/mac)\
**Post date:** [July 6, 2020, 4:39pm UTC](https://devforum.zoom.us/t/occasional-error-when-refreshing-access-zak-tokens/21377/9 "2020-07-06T16:39:21Z")

</div>

Ah brilliant, thanks for a quick response. I wanted to check the ticket because my logs pointed at exactly that issue, so thought I could give you a scenario to replicate. Thanks again!

---

<div class="post-metadata">

**Author:** ![tommy](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/tommy/32/72769_2.png) [@tommy](https://devforum.zoom.us/u/tommy)\
**Post date:** [July 8, 2020, 10:20pm UTC](https://devforum.zoom.us/t/occasional-error-when-refreshing-access-zak-tokens/21377/10 "2020-07-08T22:20:21Z")

</div>

Happy to help @mac! 🙂

Thanks,  
Tommy

---

<div class="post-metadata">

**Author:** ![DeveloperBot](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/developerbot/32/12632_2.png) [@DeveloperBot](https://devforum.zoom.us/u/DeveloperBot)\
**Post date:** [August 21, 2020, 10:37pm UTC](https://devforum.zoom.us/t/occasional-error-when-refreshing-access-zak-tokens/21377/11 "2020-08-21T22:37:36Z")

</div>

Closed on August 21, 2020, 10:37pm UTC


