Boxapi: Move/copy admin files to service account

54 views Asked by At

I have been using box since from a year. I manually upload files to Box. A few days back I integrated my nodejs code to Box (api's). I have created an app and set up Client Credentials Grant Authentication, which is a service account by default and I am able to upload files and folders. But I already have hundreds of files in my admin account. And instead of creating all those files again under my new service account, I want to move all those content to the service account. I read the docs about de-provision, but I am not sure if that is what I am looking for. Any suggestions on how can I do this?. Thanks in advance.

1

There are 1 answers

0
Elliot On

Finally, I found the solution. There are two ways(maybe more, but I found these two) to achieve this.

  1. Transfer Owned Folders
    const sourceUserID = 'exaplesourceId';
    const destinationUserID = 'exampleuserId';
    client.enterprise.transferUserContent(sourceUserID, destinationUserID)
        .then((movedFolder) => {
            resolve(movedFolder);
        }).catch((error) => {
            reject(error);
        });

For reference: https://developer.box.com/guides/users/deprovision/transfer-folders/

  1. The other way is to give access to the service account user to collaborate on existing content. We can do this via the API too.

Reference: https://developer.box.com/guides/users/deprovision/transfer-folders/