Introduction

Globus SDK

The Globus Python SDK allows you to access and control Globus services using Python code in a Jupyter Notebook

Summary of the steps

Get a Client
Get and Save Client ID
Get Some Access Tokens!
Use Your Tokens, Perform operations.

  • Use the Globus Developers page to register an application.
  • Use the drop down menu to select your institution.

Create the Project

Follow screen directions, to create a project.
Fill in the details that are required for the project.
After successfully creating a project, click on ‘add app’. Use this example tutorial .

Application registration

  • By clicking on add new app, App registration page opens.
  • Enter all the required information for the app registration.
  • Make sure, you click on “Native app” if you would like to run the app on local host otherwise, you may use the URI and other required information related to your application.
  • By clicking on “Create App,” the app is successfully created under the project.
  • For this tutorial, a ‘Native app’ is created and used same redirect URLs and scopes as specified in the tutorial.

Generating client ID

By creating an application, a Client ID is generated.
This Client ID is very important for the further steps in the process.

Accessing Jupyter notebook

Open the Jupyter Notebook and start importing libraries.
Gather the UUIDs of the endpoints you wish to exchange the information with.
The Globus Python SDK makes transfer functionality available via a TransferClient class.
We want to configure a TransferClient with an OAuth2 access token, to authenticate its connections with Globus.
The client ID generated is used.

Authenticating the application in jupyter notebook

Since the app is native app, when we run the Oauth, and this generates a link in the output.
By clicking on the link, you will be redirected to a page with the authentication code.
Copy the authentication code. This code is valid for only 10 minutes.
Every time we rerun the cell; it generates new link with new code.

The authorization code looks like this

This is very important step in accessing Globus from Jupyter notebook. The authorization code generated is copied and pasted here. By running this cell, it authenticates and lets the user perform further operations.

Transferring files in Globus

To perform the transfer operation, get the source and destination path and perform the transfer operation. This block of code generates the task ID. Task ID is used to get the status of the task and other information related to the task.

By using the generated task ID, the status of the task can also be determined.

  • Different operations can be performed. This includes:
    • Getting the previously generated task listed with their status,
    • searching for the active,
    • successful or failed status, and
    • terminating active task.
  • If the task has been successful, then you cannot terminate the task.