Top Banner
Integration with Dropbox using Mule ESB Prepared By: Rupesh Sinha Mule ESB
30
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Integration with Dropbox using Mule ESB

Integration with Dropbox

using Mule ESB

Prepared By: Rupesh Sinha

Mule ESB

Page 2: Integration with Dropbox using Mule ESB

Overview What is Dropbox?

Versions and Assumptions

Configuring Dropbox

Configuring Global properties in Mule

Configuring Dropbox Connector

Mule Flow for Dropbox Authentication

Mule Flow for retrieving Dropbox Account Info

Mule Flow for downloading a File

Mule Flow for uploading a file

Mule Flow for deleting a file

Mule flow for creating a folder

Conclusion

Page 3: Integration with Dropbox using Mule ESB

What is Dropbox?

Dropbox was founded in 2007

Dropbox is a file hosting service operated by Dropbox, Inc. ,

headquartered in San Francisco, California

It offers cloud storage, file synchronization, personal cloud,

and client software for Microsoft Windows, Mac OS

X, Linux, Android, iOS, BlackBerry OS, Windows Phone and web

browsers

Dropbox allows users to create a special folder on their computers,

which Dropbox then synchronizes so that it appears to be the same

folder (with the same contents) regardless of which computer is used

to view it. Files placed in this folder are also accessible via the

Dropbox website and mobile apps

Page 4: Integration with Dropbox using Mule ESB

Versions and Assumptions

• In this presentation, we are using

− Dropbox Cloud Connector 3.3.0

− Anypoint Studio

− Mule ESB Server 3.5.2

− Mule requester Module 1.2.0

• To integrate Dropbox with Mule ESB, you will need a Dropbox

account

• You will need to create a new Dropbox app under Dropbox

developer apps to be able to communicate with your Dropbox

account from Mule ESB application

• We will be using OAuth2 authentication to connect to Dropbox

using Mule ESB Dropbox Cloud Connector

Page 5: Integration with Dropbox using Mule ESB

Configuring Dropbox

Go to https://www.dropbox.com/developers/apps

Click on Create app button

Click on Dropbox API app

Page 6: Integration with Dropbox using Mule ESB

Select “Files and datastores” radio button

Select “No - My app needs access to files already on Dropbox” radio button

Select “All file types - My app needs access to a user's full Dropbox” radio

button

Provide an app name and click on Create app button

Provide a redirect URI for OAuth2 and click on Add button

Make a note of the App key, App secret URI as these will be used in our

Mule application

A sample screen shot is shown in the next slide

Page 7: Integration with Dropbox using Mule ESB
Page 8: Integration with Dropbox using Mule ESB

Configuring Global properties in Mule

Create a new Mule Application

Click on Global Elements tab in

your main flow

Click on Create Button

Select Property Placeholder

component

Provide your property file

location and click on OK

Page 9: Integration with Dropbox using Mule ESB

Configuring Dropbox Connector

Click on Global Elements tab in your main flow

Click on Create Button

Select Dropbox under Connector Configuration group

Add your Dropbox App Key value to App Key text box

Add your Dropbox Secret value to App Secret text box

Click on Oauth tab and specify domain, local port, remote port and

path values. These values should be same as provided in Redirect URL

during Dropbox configuration

A screen shot and sample XML configuration is shown in the next slide

Page 10: Integration with Dropbox using Mule ESB
Page 11: Integration with Dropbox using Mule ESB

Mule Flow for Dropbox Authentication

Configure a flow as shown in the below picture

The XML configuration for this flow is given in the next slide

Page 12: Integration with Dropbox using Mule ESB

If the app authorizes to Dropbox app successfully, the connector returns two

flow variables to Mule ESB flow which are “_oauthVerifier” and

“OAuthAccessTokenId”

Using Choice router, we are checking weather the flow received a valid

“OAuthAccessTokenId” or not and based on the response we are determining

the success or failure of the Dropbox authorization

Page 13: Integration with Dropbox using Mule ESB

Deploy your Mule application

Hit the following URL on the browser

http://localhost:2222/dropboxcloudconnect

Dropbox will ask you to authorize your new app to connect to Dropbox as

shown below. Below screen will be prompted every time you run the app

Click on Allow button and you should see a message printed on your browser as

“Authorization is successful”

Page 14: Integration with Dropbox using Mule ESB

Mule Flow for retrieving Dropbox Account Info

Let’s extend the previous authorize flow and use the authentication

token to retrieve the logged in user account information from

Dropbox.

Change your Mule flow as per the following flow picture

Page 15: Integration with Dropbox using Mule ESB

The XML configuration for the flow is as follows

Page 16: Integration with Dropbox using Mule ESB

In this flow, we have used get-account operation provided by Dropbox

connector to retrieve the logged in user details and print them on the browser

using Object to JSON message transformer

Deploy your app

Hit the following URL on the browser

http://localhost:2222/dropboxcloudconnect

You should now see the logged in user details printed on your browser in JSON

format

Page 17: Integration with Dropbox using Mule ESB

Mule Flow for downloading a File

Modify your previous flow as per the following picture

The XML configuration for this flow is given in the next slide

Page 18: Integration with Dropbox using Mule ESB
Page 19: Integration with Dropbox using Mule ESB

Deploy your Mule application

Hit the following URL on the browser

http://localhost:2222/dropboxcloudconnect

A message should be printed on your browser as “File downloaded successfully”

You should now see a file downloaded on your system at the given folder

location

Page 20: Integration with Dropbox using Mule ESB

Mule Flow for uploading a file

Modify your previous flow as per the following picture

Observe that we are using Mule Requestor module to read a file in the

middle of the flow. This component is not available by default and

hence you need to install this from Help -> Install New Software

The XML configuration for this flow is given in the next slide

Page 21: Integration with Dropbox using Mule ESB
Page 22: Integration with Dropbox using Mule ESB

Deploy your Mule application

Hit the following URL on the browser

http://localhost:2222/dropboxcloudconnect

A message should be printed on your browser as “File uploaded successfully”

A new file should now be uploaded on your Dropbox at the specified path

Page 23: Integration with Dropbox using Mule ESB

Mule Flow for deleting a file

Modify your previous flow as per the following picture

The XML configuration for this flow is given in the next slide

Page 24: Integration with Dropbox using Mule ESB
Page 25: Integration with Dropbox using Mule ESB

Deploy your Mule application

Hit the following URL on the browser

http://localhost:2222/dropboxcloudconnect

A message should be printed on your browser as “File deleted successfully”. In

my code I am using a file name which already exists on my Dropbox. If the files

does not exist, application will throw an error

Once the flow execution completes, the specified file will be deleted from

Dropbox

Page 26: Integration with Dropbox using Mule ESB

Mule flow for creating a folder

Modify your previous flow as per the following picture

The XML configuration for this flow is given in the next slide

Page 27: Integration with Dropbox using Mule ESB
Page 28: Integration with Dropbox using Mule ESB

Deploy your Mule application

Hit the following URL on the browser

http://localhost:2222/dropboxcloudconnect

A message should be printed on your browser as “Folder Created successfully”

A new folder should now be created on your Dropbox at the specified path

Page 29: Integration with Dropbox using Mule ESB

Conclusion

• Mule ESB Dropbox connector provides an easy way to connect to

Dropbox cloud using OAuth2 authentication and allows

performing several operations

• The latest Dropbox connector is simpler to use compared to the

previous version of Dropbox connectors

• Dropbox Connector is available for Mule ESB community edition

• Mule Request module allows to retrieve a file in the middle of

the flow and is very easy to use

• You can use Dropbox connector like FTP connector in your

application to upload files directly on Dropbox cloud storage

Page 30: Integration with Dropbox using Mule ESB