Handling oauth2 token expiration on CircleCI builds

Highlighted
New Contributor

Handling oauth2 token expiration on CircleCI builds

Hello,

 

I'm using CircleCI for a job that synchronizes some assets from a Box account into the job storage. Since the amount of files can be quite big, and with several nested directories, we're simplifying this process with rclone (https://rclone.org/). This works well both in CircleCI and in our dev environments. However, we're facing a problem in that on different runs of the Circle job (it runs 4 times a day), the sync fails because the token expires, even though only a few hours have passed between runs. This forces us to have to regenerate the token very frequently

 

It looks like Box expires tokens automatically if they're used on different machines, and the way Circle jobs are executed on different runs seems to trigger that expiration. 

 

Is there a way to work around that? Is this filtering done by IP? 

 

Thank you!

2 REPLIES 2
Highlighted
Box Employee

Re: Handling oauth2 token expiration on CircleCI builds

Hi @Slv_,

 

The issue here is most likely due to token expiration. Our access tokens will be valid for 60 minutes, then will need to be refreshed. Given that your runs are several hours apart then the token will expire during that time. Our SDKs provide automatic refresh capabilities but if that's not an option in CircleCI then yes, you'll need to manually refresh those tokens every hour.

 

- Jon

New Contributor

Re: Handling oauth2 token expiration on CircleCI builds

Hey @jcleblanc , thanks for the insights. This was a problem with the way our rclone config was being stored in regards the box tokens. Solved and now things are working well. Thanks!