Skip to content

proxystore.globus.client

Create Globus Auth clients.

get_confidential_app_auth_client

get_confidential_app_auth_client(
    client_id: str | None = None,
    client_secret: str | None = None,
) -> ConfidentialAppAuthClient

Create a confidential application authentication client.

Note

See the Globus SDK docs to learn how to create a confidential application and get the ID and secret.

Note

This function will not perform the OAuth2 flow.

Parameters:

  • client_id (str | None, default: None ) –

    Client ID. If either client_id or client_secret is None, the values will be read from the PROXYSTORE_GLOBUS_CLIENT_ID and PROXYSTORE_GLOBUS_CLIENT_SECRET environment variables.

  • client_secret (str | None, default: None ) –

    Client secret.

Returns:

Raises:

  • ValueError

    if client_id or client_secret are not provided and one or both of PROXYSTORE_GLOBUS_CLIENT_ID and PROXYSTORE_GLOBUS_CLIENT_SECRET are not set.

  • ValueError

    if the provided client_id or ID read from the environment is not a valid UUID.

Source code in proxystore/globus/client.py
def get_confidential_app_auth_client(
    client_id: str | None = None,
    client_secret: str | None = None,
) -> globus_sdk.ConfidentialAppAuthClient:
    """Create a confidential application authentication client.

    Note:
        See the [Globus SDK docs](https://globus-sdk-python.readthedocs.io/en/stable/examples/client_credentials.html#get-a-client)
        to learn how to create a confidential application and get the ID
        and secret.

    Note:
        This function will not perform the OAuth2 flow.

    Args:
        client_id: Client ID. If either `client_id` or `client_secret` is
            `None`, the values will be read from the
            `PROXYSTORE_GLOBUS_CLIENT_ID` and `PROXYSTORE_GLOBUS_CLIENT_SECRET`
            environment variables.
        client_secret: Client secret.

    Returns:
        Authorization client.

    Raises:
        ValueError: if `client_id` or `client_secret` are not provided and
            one or both of `PROXYSTORE_GLOBUS_CLIENT_ID` and
            `PROXYSTORE_GLOBUS_CLIENT_SECRET` are not set.
        ValueError: if the provided `client_id` or ID read from the environment
            is not a valid UUID.
    """
    if client_id is None or client_secret is None:
        client_id, client_secret = _get_client_credentials_from_env()

    try:
        uuid.UUID(client_id)
    except ValueError as e:
        raise ValueError(
            f'Client ID "{client_id}" is not a valid UUID. '
            'Did you use the username instead of ID?',
        ) from e

    return globus_sdk.ConfidentialAppAuthClient(
        client_id=str(client_id),
        client_secret=str(client_secret),
    )

get_native_app_auth_client

get_native_app_auth_client(
    client_id: str = _PROXYSTORE_GLOBUS_APPLICATION_ID,
    app_name: str = "proxystore-client",
) -> NativeAppAuthClient

Create a native app authentication client.

Note

This function will not perform the OAuth2 flow.

Parameters:

  • client_id (str, default: _PROXYSTORE_GLOBUS_APPLICATION_ID ) –

    Application ID. Defaults to the ProxyStore application ID.

  • app_name (str, default: 'proxystore-client' ) –

    Application name.

Returns:

Source code in proxystore/globus/client.py
def get_native_app_auth_client(
    client_id: str = _PROXYSTORE_GLOBUS_APPLICATION_ID,
    app_name: str = 'proxystore-client',
) -> globus_sdk.NativeAppAuthClient:
    """Create a native app authentication client.

    Note:
        This function will not perform the OAuth2 flow.

    Args:
        client_id: Application ID. Defaults to the ProxyStore application ID.
        app_name: Application name.

    Returns:
        Authorization client.
    """
    return globus_sdk.NativeAppAuthClient(
        client_id=client_id,
        app_name=app_name,
    )

is_client_login

is_client_login() -> bool

Check if Globus client identity environment variables are set.

Based on the Globus Compute SDK's is_client_login().

Returns:

  • bool

    True if PROXYSTORE_GLOBUS_CLIENT_ID and PROXYSTORE_GLOBUS_CLIENT_SECRET are set.

Source code in proxystore/globus/client.py
def is_client_login() -> bool:
    """Check if Globus client identity environment variables are set.

    Based on the Globus Compute SDK's
    [`is_client_login()`](https://github.com/funcx-faas/funcX/blob/8f5b59075ae6f8e8b8b13fe1b91430271f4e0c3c/compute_sdk/globus_compute_sdk/sdk/login_manager/client_login.py#L24-L38){target=_blank}.

    Returns:
        `True` if `PROXYSTORE_GLOBUS_CLIENT_ID` and \
        `PROXYSTORE_GLOBUS_CLIENT_SECRET` are set.
    """
    try:
        _get_client_credentials_from_env()
    except ValueError:
        return False
    else:
        return True