Box Cloud Storage Integration with Mule

Author: Nishant Banga

Box is a cloud computing business which provides file sharing, collaborating, and other tools for working with files that are uploaded to its servers. Users can determine how their content can be shared with other users.

Box enables quick access to files from any device, so they are free to be productive wherever they are. Plus, Box’s cloud storage ensures you always have an online backup handy and can access data from anywhere.

PROBLEM STATEMENT: To connect to client’s box storage and access files and folders to further process the data. Here we will see how to build a connection with box cloud from MuleSoft.
REQUISITES: Access to box cloud storage and Developer account on box.


  1. Go to the box developer console and create a new app. 
  1. After creating the app, click on configurations to get the Client ID and secret. Also, you have to add the redirect URI there.
  1. Set redirect URI as “http://localhost:8081/oathcallback” (can be anything, but we have to add the same in the studio as well). A redirect URI, or reply URL, is the location that the authorization server will send the user to once the app has been successfully authorized and granted an authorization code or access token.
  2. Copy the client ID and secret.
  3. In the studio you can add a Box connector by searching it in the exchange as “mule-box-connector” (I have used version 4.0.1).
  4. Add the box connector configuration in the global file with following set of values: 
  • localCallbackUrl will be your Http listener configuration name. 
  • ClientId- secret is what you copied from the app in the developer console.
  • externalCallbackUrl will be the redirect URI you entered in the box developer console.

Rest all values are the same and can be used as it is.

  1. Logout from the developer console of the box. 
  2. Deploy your application and before hitting any endpoint, hit localAuthorizationUrl from browser. It will ask to grant some access. This is a one time process.
    Upon doing this, box will recognize our host to be secure for the user and will grant any transactions in future to flow without any authorization issues.
  3. Connection has now been established successfully.
  4. Now you can hit any endpoint of your application. 
POC for Getting Folder Contents:

This POC will use the “Get Folder” component which is used to get details of the folder and it’s content in json format. We just have to pass the folder ID in the configuration (it can be seen in the end of URL).

<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:mule-box-connector="" xmlns:http=""
	xmlns:doc="" xmlns:xsi="" xsi:schemaLocation="">
	<flow name="box-demo-blogFlow" doc:id="387b7768-9bd2-46a6-a10f-331de305d534" >
		<http:listener doc:name="HTTP Listener" doc:id="f7d76521-4dc3-4209-a504-a763f7b76e03" config-ref="HTTP_Listener_config" path="/demo"/>
		<mule-box-connector:get-folder doc:name="get files present in folder" doc:id="d4de0460-3b6f-4028-953c-aa6461528588" config-ref="Mule_box_connector_Config" folder-id="${common.folder-id}"/>

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:salesforce-analytics=""
	xmlns:db="" xmlns:secure-properties=""
	xmlns:file="" xmlns:http="" xmlns="" xmlns:doc="" xmlns:xsi="" xsi:schemaLocation="
	<http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" doc:id="df459656-9a9f-4153-9f56-d5a11f15cb19" >
		<http:listener-connection host="${}" port="${http-listener.port}" />
	<configuration-properties doc:name="Configuration properties" doc:id="25d7d0e7-2573-4ffc-8f65-50c657cdc5f4" file="application-properties\config-${env}.yaml" />
	<mule-box-connector:config name="Mule_box_connector_Config" doc:name="Mule-box-connector Config" doc:id="7216cd47-6614-4d07-9724-9bbd97bc541d" property_clientId="${box-connector.clientId}" property_clientSecret="${box-connector.clientSecret}" property_host="${}" property_port="${box-connector.port}" property_basePath="${box-connector.basePath}" property_protocol="${box-connector.protocol}" property_localCallbackPath="${box-connector.localCallbackPath}" property_localCallbackConfig="${box-connector.localCallbackConfig}" property_externalCallbackUrl="${box-connector.externalCallbackUrl}" property_localAuthorizationUrl="${box-connector.localAuthorizationUrl}" property_authorizationUrl="${box-connector.authorizationUrl}" property_accessTokenUrl="${box-connector.accessTokenUrl}"/>    

We use cookies on this site to enhance your user experience. For a complete overview of how we use cookies, please see our privacy policy.