Skip to main content
ben.bahrman@headintheclouddev.
April 24, 2024
Question

Error when refreshing token

  • April 24, 2024
  • 13 replies
  • 340 views

We are getting intermittent errors when refreshing Oauth2 tokens in our Rest API integration. We are using a legacy token (Admin > App Integration > General >App Integrations > Custom OAuth apps) and the app has been working in our test environment for months. We recently deployed to production and more users are using it more regularly. 

The same user will get a refresh token error one moment and then when they try again it errors (see below).

We did have a scheduled process that was retrieving all documents from each user and therefore hitting the API more frequently (once per user every 15 minutes),  we have stopped that process  temporarily to see if that helps, but would like to know if there are any other known issues which would be causing the intermittent issues.

 

{"type":"http.ClientResponse","code":400,"headers":{"Alt-Svc":"h3=\":443\"; ma=93600","alt-svc":"h3=\":443\"; ma=93600","connection":"close","Connection":"close","Content-Length":"166","content-length":"166","Content-Type":"application/json","content-type":"application/json","Date":"Wed, 24 Apr 2024 22:17:28 GMT","date":"Wed, 24 Apr 2024 22:17:28 GMT","Strict-Transport-Security":"max-age=31536000","strict-transport-security":"max-age=31536000","Vary":"Origin","vary":"Origin","Via":"1.1 mono001.prod-phx-na15.core.ns.internal","via":"1.1 mono001.prod-phx-na15.core.ns.internal","x-lucid-flow-id":"e93e10683a3fe85b","X-Lucid-Flow-Id":"e93e10683a3fe85b"},"body":"{\"error\":\"invalid_grant\",\"error_description\":\"Invalid client id, client secret, or refresh token\",\"error_uri\":\"https://developer.lucid.co/api/#general-oauth2-errors\"}"}

 

Comments

ben.bahrman@headintheclouddev.
April 26, 2024

Thanks for the additional thought @Michael B101, Our account level authentication is my biggest concern because multiple users could be using it at a time (our embeds are authenticated at the account scope), we won’t have more than one operation per UI user at any given time (we only load one embed at a time - whichever is the one actively being viewed), but with the system process and any number of users there could be up to 2 refreshes at the user level (if a user happens to be creating a document while the system is updating metadata on their documents) and any number at the account level.

I added in some additional logic on the retry to ensure that it checks back to the saved token values if the call to Lucid fails. That way if we do happen to have two processes running they’ll check back in with each other if one fails. I think that this combined with the 1 minute grace period you mentioned earlier in the thread should handle thing well.

So far today everything has been working well - no further issues since implementing the retry logic and resetting everything.

Thanks for all the help.

 

 

Michael B
Lucid product team
April 26, 2024

Super glad to hear it. As a matter of professional experience, I remain a bit concerned you will have problems. Hopefully, next week will go smoothly.  Of course, you can resolve this thread whenever you feel the original question has been handled.

Michael B
Lucid product team
May 16, 2024

We have deployed a fix that ensures all requests to refresh an oauth2 token will be atomic, even when processed with sub-second timing. No action is needed, I just wanted to follow up that the underlying issue was resolved for posterity.