This is a guide on how to make a successful connection from Appsmith to Box.com using a developer token or using authentication via Oauth2.0.
-
Navigate to the developer dashboard in Box.
-
Click on My Apps.
-
In OAuth 2.0 Redirect URI add new uri and put appsmith uri
-
In
Applications Scopes
select the option calledWrite all files and folders stored in box
Import this CURL
in appsmith for automatic configuration
curl https://api.box.com/2.0/folders/0 -H "Authorization: Bearer <<Token>>" -H "Content-Type: application/json"
- Go to datasources in Appsmith
- Select Athenticated API
- Set the configuration parameters as shown below
URL: `https://api.box.com/2.0/`
Headers: `Content-Type`: `application/json`
Authentication Type: `OAuth 2.0`
Grant Type: `Authorization Code`
Add Access Token To: `Request Header`
Access Token URL: `https://api.box.com/oauth2/token`
Client ID: `<<your_client_id>>`
Client Secret: `<<your_client_secret>>`
Authorization URL: `https://account.box.com/api/oauth2/authorize`
Add you Redirect URL in theOAuth 2.0 Redirect URI
in your box.com
console
- Press the authorize button
note: sometimes you will get a message that says something went wrong, just authorize the data source again
Http method: GET
URL: https://api.box.com/2.0/folders/0
Headers: Content-Type: application/json
- You can link it to a table to show the files by writing this in the table data:
{{Get_Files.data.item_collection.entries}}
- Use a widget input
- Set the default value of the input to this
{{Table1.selectedRow.id}}
Http method: GET
URL: https://api.box.com/2.0/files/{{Table1.selectedRow.id}}
Headers: content-type: application/json
- Use a widget input
- Set the default value of the input to this
{{Table1.selectedRow.id}}
Note: You can use the same input configured above
Http method: DELETE
URL: https://api.box.com/2.0/files/{{Table1.selectedRow.id}}
Http method: POST
URL: `https://upload.box.com/api/2.0/files/content`
Headers: `content-type: multipart/form-data`
Body: In tab `MULTIPART_FORM_DATA` - `attributes:{"name":"{{File_data.files[0].name}}", "parent":{"id":"0"}}` - `file: {{File_data.files[0]}}`