Skip to main content
Question

Authentication to be used for background automation

  • May 22, 2025
  • 3 replies
  • 46 views

Forum|alt.badge.img

Which authentication can be used for background automation?

For example, suppose I want to push the files from local drive to the box without any manual intervention for longer duration.

OAuth 2.0 cannot be used in this case as every time an application uses the Refresh Token to get a new Access Token the Refresh Token is invalidated and a new Refresh Token is returned with the new Access Token. This new Refresh Token is then again only valid for 1 use within 60 days.

When an Access Token is requested using JWT or Client Credentials Grant or App Token Auth, the data is stored within the application's Service Account and not a user's account

3 replies

Forum|alt.badge.img

Hi Rashmi

In the scenario you are describing I would recommend you using either JWT or Client Credentials Grant as you have discovered. You are correct that initially this will authenticate as the service account associated with the application. You have three options:

1. Invite the service account as collaborator on the folders you need to push files to. https://developer.box.com/guides/collaborations/share-content/

2. Use the 'As-User' header to impersonate the user you want to perform the upload as (and who has access) https://developer.box.com/guides/authentication/jwt/as-user/

3. Generate an access token for the user you want to perform the upload https://developer.box.com/guides/authentication/jwt/user-access-tokens/

Best regards,
Peter Christensen, Platform Solutions Engineer, Box


Forum|alt.badge.img

Hi Peter

Thank you for your response.

Among the three options that you have suggested, I have tried the first one. It works as expected.

But I have a query regarding this approach. Can we invite the service account as collaborator on the root folder?


Forum|alt.badge.img

Hi Rashmi

No, you cannot add collaborators to  the root folder/folder '0' 

Rgds,

Peter