Note: This is not the plugin distributable! This is the source code. To find the installable plugin, go into the 'Releases' tab, and download a stable version.
Plugin: Box Utilities
Author: Timothy Bula
Date: 02/05/16
This plugin is protected under the Eclipse Public License - v 1.0 License
The Box Utilities plugin provides integration with Box via Web Services, utilizing the Box Java-SDK. Version 1 of the the plugin has support for multi-step user authentication and file upload operations.
Box Java SDK
Box Content API Documentation
Box Developer Account FAQ
- Box Developer Account Request Form
- Box Developer Application Create Application
- Box App configuration - App Auth and App Users enabled + more Guide
Performs the first leg of OAuth2 authentication. Note: Not compatiable with Java v6
- Entity ID - enterpriseID on account info tab on Admin Console
- Client ID - application’s client_id. Available on application settings webpage
- Client Secret - application’s client_secret. Available on application settings webpage
- Public Key ID - created when adding public key to application.
- Private Key - generated locally
- Private Key Path - private key must be added to the UCD step to create the file
- Private Key Password - set private key in settings if desired.
- Creates Enterprise JWT assertion with provided information from Box app setting
- Requests enterprise authentication
- Prints enterprise auth token to the log
Retrieves/creates the App User
- Enterprise Auth Token - enterprise auth token from first leg of authentication
- App User Name - name of app user on the developer enterprise account. Will be created on the enterprise account if not found. Needed for Content API
- Establishes API connection to Box with enterprise auth token
- Seaches for provided App User name and finds match
- If cannot find App User, it creates a new one with provided name
- Prints found/created App User ID to the log
Performs second leg of OAuth2 authentication and allows Content API to be used. Note: Not compatiable with Java v6
- App User ID - ID of the App User. Retrieved in previous script. Can be manually entered.
- Client ID - application’s client_id. Available on application settings webpage
- Client Secret - application’s client_secret. Available on application settings webpage
- Public Key ID - created when adding public key to application.
- Private Key - generated locally
- Private Key Path - private key must be added to the UCD step to create the file
- Private Key Password - set private key in settings if desired.
- Uses App User Id to create User JWT assertion
- Requests authentication
- Prints auth token to log
Locates/creates folder under specified parent folder
- App User Auth Token - auth token necessary for Box API calls
- Folder - folder to be created or found
- Parent Folder ID - ID of parent folder. Can be found on the Box web app in the url when inside the folder
- Parent Folder - name of parent folder for folder to be located/created within. Will not necessarily find the correct folder. ID is preferred method for specifying folder
- Establishes connection to Box with app user auth token
- Uses one of three methods based on what information is passed to it: Parent Folder ID, Parent Folder Name, Nothing
- (a) Locates parent folder with the ID. Looks for the new folder name passed to it. Creates folder if cannot find it
- (b) Searches Box account for parent folder by name. Looks for new folder name passed to it. Creates the new folder if cannot find it. Does not guarentee the correct folder is found if multiple folders have the same name in the account.
- (c) No parent folder info is passed to it, so it uses the Box root folder as the parent folder. Looks for new folder in it and creates one if it doesn't find it.
- Prints found/created folder id to the log
Uploads file to box account
- App User Auth Token - auth token necessary for Box API calls
- File Path - folder to be created or found
- File Name - name of the file to be uploaded. Optional and defaults to file name from File Path
- Parent Folder ID - ID of parent folder for file to be uploaded to. Can be found on the Box web app in the url when inside the folder
- Establishes connection to Box with auth token
- Performs preflight check on file to be upload (file size, naming conflicts, etc.)
- If preflight check fails because of naming collision, find existing file in the parent folder and attempt to upload new version
- If preflight check is successful, upload file to parent folder
- Prints uploaded file id to the log
Gets the direct download url for a file on box
- App User Auth Token - auth token necessary for Box API calls
- File ID - ID of file to get the file downloadurl of
- Establishes connection to Box with auth token
- Finds file by id
- Creates sharedlink and gets direct download url
- Prints direct download url to the log