name | slug | description | deployUrl |
---|---|---|---|
Box Web App Integration Demo |
box-web-app-integration-demo |
This template simplifies the development of web app integrations with Box, providing a seamless setup for OAuth 2.0 authorization, token management, and file operations. |
This demo showcases a web app integration with Box, leveraging Vercel for hosting and serverless functions. It demonstrates the OAuth 2.0 authorization flow, secure token exchange, and a file rename operation within Box, all orchestrated through a modern web interface.
index.html
: Provides the structure for the web application, including input fields for the new file name and a button to initiate the file rename operation.styles.css
: Styles the web application, ensuring a modern and sophisticated look, including styling for the file renaming input and button.scripts.js
: Handles client-side logic, including:- Extracting URL parameters to obtain the
auth_code
. - Invoking the
/api/exchange
serverless function to exchange theauth_code
for an access token. - Providing a UI for renaming a file and invoking the
/api/renameFile
serverless function to carry out the operation. - Enhanced error handling to display meaningful error messages based on Box API responses.
- Extracting URL parameters to obtain the
api/exchange.js
: A serverless function that exchanges anauth_code
for an access token with Box. It securely handles credentials and communicates with Box's OAuth 2.0 token endpoint, returning the access token to the client-side application.api/renameFile.js
: Another serverless function that uses the access token to rename a file in Box. It makes an authorized request to Box's/files/:id
endpoint, carrying out the file rename operation as instructed by the client-side application.
To use this demo, you'll need to configure an application in Box. Here's how:
-
Create a Box Developer Account: If you don't already have one, sign up at Box Developers.
-
Create a New Application: Go to the Box Developer Console, click 'Create New App', choose 'Custom App' and then 'User Authentication with OAuth 2.0'. Name your app accordingly.
-
Set Application Scopes: Ensure your application has the necessary permissions, such as 'Read and write all files and folders stored in Box'.
-
Configure Integrations Tab: For detailed steps and additional configurations, refer to the Box Web App Integrations Guide.
For detailed information on Box APIs and integration capabilities, visit the Box Developer Documentation.
This project is open source and available under the MIT License.