{"id":9014,"library":"globus-sdk","title":"Globus SDK for Python","description":"The Globus SDK for Python provides a convenient Pythonic interface to Globus web APIs, including the Auth, Transfer, Search, Flows, and Compute services. Currently at version 4.5.0, the library maintains an active development pace with minor releases typically occurring on a monthly or bi-monthly basis, incorporating new features, bug fixes, and Python version support updates.","status":"active","version":"4.5.0","language":"en","source_language":"en","source_url":"https://github.com/globus/globus-sdk-python","tags":["globus","auth","transfer","search","flow","compute","identity","data","cloud"],"install":[{"cmd":"pip install globus-sdk","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Requires Python 3.9 or newer.","package":"python","optional":false}],"imports":[{"symbol":"AuthClient","correct":"from globus_sdk import AuthClient"},{"symbol":"TransferClient","correct":"from globus_sdk import TransferClient"},{"note":"Used for applications that cannot securely store a client secret, like desktop apps or CLI tools.","symbol":"NativeAppAuthClient","correct":"from globus_sdk import NativeAppAuthClient"},{"note":"Used for applications that can securely store a client secret, like web apps or backend services.","symbol":"ConfidentialAppAuthClient","correct":"from globus_sdk import ConfidentialAppAuthClient"},{"note":"The recommended authorizer for long-lived access in user-facing applications.","symbol":"RefreshTokenAuthorizer","correct":"from globus_sdk import RefreshTokenAuthorizer"},{"symbol":"FlowsClient","correct":"from globus_sdk import FlowsClient"},{"symbol":"SearchClient","correct":"from globus_sdk import SearchClient"}],"quickstart":{"code":"import os\nimport globus_sdk\n\n# NOTE: Register your app at developers.globus.org and get a Client ID.\n# For a native app, ensure 'Native App' is checked and set 'Redirects' to\n# 'https://auth.globus.org/v2/web/auth-code'\nCLIENT_ID = os.environ.get('GLOBUS_CLIENT_ID', 'YOUR_NATIVE_APP_CLIENT_ID')\n\ndef authenticate_and_list_endpoints():\n    client = globus_sdk.NativeAppAuthClient(CLIENT_ID)\n    client.oauth2_start_flow(refresh_tokens=True)\n\n    authorize_url = client.oauth2_get_authorize_url()\n    print(f\"Please go to this URL and login:\\n\\n{authorize_url}\\n\")\n\n    auth_code = input(\"Please enter the code here: \").strip()\n    tokens = client.oauth2_exchange_code_for_tokens(auth_code)\n\n    # Store the tokens securely for future use. For this example, we just extract them.\n    transfer_tokens = tokens.by_resource_server['transfer.api.globus.org']\n    transfer_access_token = transfer_tokens['access_token']\n    transfer_refresh_token = transfer_tokens['refresh_token']\n\n    # Use a RefreshTokenAuthorizer for long-lived access\n    authorizer = globus_sdk.RefreshTokenAuthorizer(\n        transfer_refresh_token, client, access_token=transfer_access_token\n    )\n    transfer_client = globus_sdk.TransferClient(authorizer=authorizer)\n\n    print(\"\\nYour Globus endpoints:\")\n    for ep in transfer_client.endpoint_search(filter_scope='managed'):\n        print(f\"  {ep['display_name']} (ID: {ep['id']})\")\n\nif __name__ == \"__main__\":\n    if CLIENT_ID == 'YOUR_NATIVE_APP_CLIENT_ID':\n        print(\"WARNING: Replace 'YOUR_NATIVE_APP_CLIENT_ID' with your actual Globus Client ID or set the GLOBUS_CLIENT_ID environment variable.\")\n    authenticate_and_list_endpoints()","lang":"python","description":"This quickstart demonstrates a typical Native App authentication flow to obtain refresh and access tokens, then uses these tokens to create a `TransferClient` and list the user's Globus endpoints. It assumes you have registered a Native App at developers.globus.org and set its redirect URL. For production use, tokens should be stored securely."},"warnings":[{"fix":"Consult the official 'Upgrading' guide for a detailed migration path. Generally, remove `transfer_client` from `TransferData`/`DeleteData` constructors, instantiate `AuthClient` without `client_id` (it's implicit from `NativeAppAuthClient`/`ConfidentialAppAuthClient`), and replace `MutableScope` with `Scope`.","message":"The SDK underwent significant breaking changes between v3.x and v4.0.0. Key changes include `TransferData` and `DeleteData` no longer accepting a `transfer_client` parameter, `AuthClient` no longer directly accepting or exposing `client_id`, and `MutableScope` being removed in favor of `Scope`.","severity":"breaking","affected_versions":"4.0.0 and later"},{"fix":"Upgrade your Python environment to Python 3.9 or newer. The current recommended minimum is Python 3.9.","message":"Support for Python 3.8 was removed in version 4.2.0 of the `globus-sdk`.","severity":"breaking","affected_versions":"4.2.0 and later"},{"fix":"Be aware that code using experimental components may break in minor releases. Avoid using them in production for critical features unless you are prepared to adapt to frequent changes. Stable interfaces will eventually move out of `experimental`.","message":"The `globus_sdk.experimental` module contains unstable interfaces (e.g., `TransferClientV2`, `gcs_downloader`). These are subject to breaking changes without a major version bump and are intended for community feedback.","severity":"gotcha","affected_versions":"4.x.x (since 4.5.0 for specific modules)"},{"fix":"Create service client objects *after* process forking. In multi-processing applications, ensure there is only one service client instance created per process.","message":"Globus SDK client objects hold networking sessions. Using a single client object across multiple processes (e.g., after `fork()` or in separate threads without proper synchronization) is considered unsafe and can lead to unexpected behavior or resource contention.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Ensure all necessary scopes (e.g., `TransferClient.scopes.all`, `AuthClient.scopes.view_identity_set`) are requested in `oauth2_start_flow` or `oauth2_client_credentials_tokens`. Re-run the authentication flow to prompt the user for consent if a user-based flow is used. For automated applications, verify the client has been granted the required scopes.","cause":"The application or user lacks the necessary consent (scopes) to perform the requested action. This often happens when the required scopes were not requested during the OAuth2 flow or the user did not grant them.","error":"globus_sdk.exc.GlobusAPIError: 403 Forbidden - 'ConsentRequired'"},{"fix":"If your application is confidential (can securely store a secret), ensure you provide both `client_id` and `client_secret` to `ConfidentialAppAuthClient`. If your application is a native/public client (e.g., desktop app, CLI), use `NativeAppAuthClient` instead, which does not require a client secret.","cause":"Attempting to instantiate `ConfidentialAppAuthClient` without providing a `client_secret`, or using it when a `NativeAppAuthClient` would be more appropriate for a public client.","error":"globus_sdk.exc.GlobusSDKUsageError: A 'client_secret' is required for ConfidentialAppAuthClient"},{"fix":"Remove the `transfer_client` argument from calls to `TransferData(...)` and `DeleteData(...)`. The clients are no longer passed directly into these data constructs.","cause":"You are likely using `globus-sdk` v4.0.0 or later, but your code is still passing a `transfer_client` argument to the `TransferData` or `DeleteData` constructors, which was removed in v4.","error":"TypeError: TransferData.__init__() got an unexpected keyword argument 'transfer_client'"},{"fix":"Check your network connectivity and firewall rules. Ensure that outbound connections to Globus API domains (e.g., auth.globus.org, transfer.api.globus.org) are allowed. If using a proxy, ensure environment variables like `HTTP_PROXY` and `HTTPS_PROXY` are correctly configured.","cause":"The SDK failed to establish a connection to the Globus API server, likely due to network issues, a firewall blocking the connection, or incorrect proxy settings.","error":"globus_sdk.exc.NetworkError: ConnectionRefusedError: [Errno 111] Connection refused"}]}