BaseClient

All service clients support the low level interface, provided by the BaseClient, from which all client types inherit.

A client object contains a transport, an object responsible for sending requests, encoding data, and handling potential retries. It also may include an optional authorizer, an object responsible for handling token authentication for requests.

BaseClient

class globus_sdk.BaseClient(*, environment=None, base_url=None, app=None, app_scopes=None, authorizer=None, app_name=None, transport_params=None)[source]

Abstract base class for clients with error handling for Globus APIs.

Parameters:
  • app (GlobusApp | None) – A GlobusApp which will be used for handling authorization and storing and validating tokens. Passing an app will automatically include a client’s default scopes in the app’s scope requirements unless specific app_scopes are given. If app_name is not given, the app’s app_name will be used. Mutually exclusive with authorizer.

  • app_scopes (list[Scope] | None) – Optional list of Scope objects to be added to app’s scope requirements instead of default_scope_requirements. Requires app.

  • authorizer (GlobusAuthorizer | None) – A GlobusAuthorizer which will generate Authorization headers. Mutually exclusive with app.

  • app_name (str | None) – Optional “nice name” for the application. Has no bearing on the semantics of client actions. It is just passed as part of the User-Agent string, and may be useful when debugging issues with the Globus Team. If both``app`` and app_name are given, this value takes priority.

  • base_url (str) – The URL for the service. Most client types initialize this value intelligently by default. Set it when inheriting from BaseClient or communicating through a proxy. This value takes precedence over the class attribute of the same name.

  • transport_params (dict[str, t.Any] | None) – Options to pass to the transport for this client

All other parameters are for internal use and should be ignored.

scopes: ScopeBuilder | None = None

the scopes for this client may be present as a ScopeBuilder

get(path, *, query_params=None, headers=None, automatic_authorization=True)[source]

Make a GET request to the specified path.

See request() for details on the various parameters.

Return type:

GlobusHTTPResponse

post(path, *, query_params=None, data=None, headers=None, encoding=None, automatic_authorization=True)[source]

Make a POST request to the specified path.

See request() for details on the various parameters.

Return type:

GlobusHTTPResponse

delete(path, *, query_params=None, headers=None, automatic_authorization=True)[source]

Make a DELETE request to the specified path.

See request() for details on the various parameters.

Return type:

GlobusHTTPResponse

put(path, *, query_params=None, data=None, headers=None, encoding=None, automatic_authorization=True)[source]

Make a PUT request to the specified path.

See request() for details on the various parameters.

Return type:

GlobusHTTPResponse

patch(path, *, query_params=None, data=None, headers=None, encoding=None, automatic_authorization=True)[source]

Make a PATCH request to the specified path.

See request() for details on the various parameters.

Return type:

GlobusHTTPResponse

request(method, path, *, query_params=None, data=None, headers=None, encoding=None, allow_redirects=True, stream=False, automatic_authorization=True)[source]

Send an HTTP request

Parameters:
  • method (str) – HTTP request method, as an all caps string

  • path (str) – Path for the request, with or without leading slash

  • query_params (dict[str, Any] | None) – Parameters to be encoded as a query string

  • headers (dict[str, str] | None) – HTTP headers to add to the request. Authorization headers may be overwritten unless automatic_authorization is False.

  • data (None | str | bytes | Dict[str, Any] | PayloadWrapper) – Data to send as the request body. May pass through encoding.

  • encoding (str | None) – A way to encode request data. “json”, “form”, and “text” are all valid values. Custom encodings can be used only if they are registered with the transport. By default, strings get “text” behavior and all other objects get “json”.

  • allow_redirects (bool) – Follow Location headers on redirect response automatically. Defaults to True

  • stream (bool) – Do not immediately download the response content. Defaults to False

  • automatic_authorization (bool) – Use this client’s app or authorizer to automatically generate an Authorization header.

Raises:

GlobusAPIError – a GlobusAPIError will be raised if the response to the request is received and has a status code in the 4xx or 5xx categories

Return type:

GlobusHTTPResponse