Strange refresh token behaviour

Hello, we face a problem with authorization through the access_token/refresh_token pair when working with the UiPath Orchestrator API for our system. Additionally, we have an automated system that monitors the expiration time of the access_token. If it is about to expire, the system requests a new token using the refresh_token, retrieves the new token pair from the response, and updates their values in the database. However, we observe a pattern that approximately every 60 days, a new request for a new token pair results in an error with the message “invalid_grant.” After this, we have to recreate the connector from scratch.

Examples:

  1. Connector created: “2023-12-04 05:50:49”,
  • Token pairs were successfully updated: “2024-02-02 05:48:02.”
  • Last expires_on value: 2024-02-02 06:48:02.
  • After this, we consistently encounter the “invalid_grant” error.
  1. Connector created: “2023-10-02 06:21:25”,
  • Token pairs were successfully updated: “2023-12-01 06:17:15.”
  • Last expires_on value: 2023-12-01 07:17:15.
  • After this, we consistently encounter the “invalid_grant” error.

We are seeking recommendations or guidance on overcoming this issue and ensuring the continued proper functioning with the Orchestrator API. Additionally, if there are any insights on improving our automated system for token renewal and database update, they would be greatly appreciated.

Thank you for your assistance and attention to this matter!

Have you also checked the following:

as authentication nowadays has advanced to OAuth2

We use that way
Use:

https://cloud.uipath.com/identity_/connect/authorize

To obtain auth code, then using the auth code and authentication details (client_id and client_secret) to obtain access_token, and then get refresh token and store pair,

The token verification occurs every minute, and if there is less than half an hour left until expires_on, we refresh the token pair.
For obtain a new pair we use route from instruction.