JMP® can connect to cloud services and third-party applications, including Dropbox®, Snowflake®, and Databricks®, by using OAuth 2.0, an industry-standard authorization framework that enables secure access to protected resources. This note demonstrates how to use the JMP OAuth JMP Scripting Language (JSL) function to access a CSV file stored in Dropbox*. To replicate the steps in this JMP Note, only a free Dropbox account is needed.
* Dropbox® is used only as an example application in this document. Configuration steps, developer settings, and account requirements are controlled by Dropbox and are subject to change. For assistance with Dropbox account configuration, contact Dropbox Support or consult the Dropbox Developer documentation.
There are three steps in this process:
- Create a Developer App
- Create a JSL Script
- Run the JSL Script
1. Create a Developer App
The target application must be configured to allow JMP to connect to it. This involves setting values in the developer interface.
When creating the Dropbox Developer App, the following must be set:
- Scope: Configure the following OAuth scopes to allow JMP to read and write the target file:
- files.metadata.read
- files.content.read
- files.content.write
- Redirect URI: The endpoint to which Dropbox returns the authorization response after successful authentication.
**Alternatively, you can use https://localhost:{port number}, such as https://localhost:5305, to avoid collisions with local web servers.
Record the following values from the Dropbox Developer App configuration. These values will be required when configuring the JMP OAuth function:
- Authorization URL (web address, found in app documentation)
- Token URL (web address, found in app documentation)
- App Key: This will become the Client_ID in the JMP OAuth script
- App Secret: This will become the Client_Secret in the JMP OAuth script
- The Scope variables (from step 1. above)
- The URI address (from step 2. above)
To complete step 1, a sample CSV file was added to the Dropbox account. The sample file, DB_OAuthTest.csv, is included with this technical note.
2: Create a JSL Script
After the Dropbox Developer App has been configured, create a JSL script that uses the OAuth function to authenticate and obtain an access token. The script will use the values collected during developer app setup. In the JSL Script, the values from the Developer App are provided to JMP:
- auth_url: https://www.dropbox.com/oauth2/authorize
- token_url: https://api.dropbox.com/oauth2/token
- redirect_url: https://127.0.0.1
- client_id: App Key (from Dropbox)
- client_secret: App Secret (from Dropbox)
We also will need to provide the Scope set in the developer app. In this case, it is read/write access:
- files.metadata.read
- files.content.read
- files.content.write
These values are used in the JMP JSL Script to establish an authorized connection to the developer app. After successful authentication, JMP can store the OAuth token.
To complete step 2, a sample JSL Script, DropBox_OAuthTest.jsl, is included with this technical note.
In the attached script, the JSL is storing the token in the JMP application data directory: %AppData%\JMP\{JMP Product}\{version}. Future connections can reuse the stored token until reauthorization is required.
See the Get Authorization Header function in the JMP Script Index for more information.
After authentication is complete, JMP uses the HTTP Request function together with the OAuth access token to access the Dropbox API and retrieve the target CSV file. The returned file contents are then opened as a JMP data table.
Please look at the JSL script to see how the code is organized.
For more information about the JMP OAuth function, please see the OAuth section in the JMP Scripting Guide.
3: Run the JSL Script
Once the script is created, run the JSL Script. This will prompt JMP to open a browser window and establish a connection with Dropbox. When prompted, provide your Dropbox credentials.
Once the credentials are successfully entered, JMP will open a JMP data table and pull in the CSV file data.
At this point, JMP has successfully authenticated with Dropbox, accessed the requested CSV file, and loaded the data into a JMP data table. The same general approach can be used with other OAuth-enabled services by substituting the appropriate authorization URLs, token URLs, scopes, and API endpoints.
For additional options, please see the OAuth section in JMP Help.
If you have additional questions that this note did not answer, please contact JMP Technical Support at [email protected] or via phone at 1-800-450-0135.