GSpace Client

The main client class for accessing Google Workspace services.

Class Definition

python
class GSpace:
    def __init__(
        self,
        credentials: str | Path,
        auth_type: str = "OAuth2",
        scopes: list[str] | None = None,
    )

Factory Methods

from_oauth

Create a GSpace client using OAuth2 authentication.

python
@classmethod
def from_oauth(
    cls,
    credentials_file: str | Path,
    scopes: list[str]
) -> GSpace

Parameters:

  • credentials_file: Path to OAuth2 client credentials JSON file
  • scopes: List of Google API scopes

Returns: GSpace client instance

Example:

python
gspace = GSpace.from_oauth(
    credentials_file="credentials.json",
    scopes=["calendar", "gmail"]
)

from_service_account

Create a GSpace client using Service Account authentication.

python
@classmethod
def from_service_account(
    cls,
    service_account_file: str | Path,
    scopes: list[str]
) -> GSpace

Service Methods

calendar()

Get the Calendar service instance.

python
calendar = gspace.calendar()

gmail()

Get the Gmail service instance.

python
gmail = gspace.gmail()

drive()

Get the Drive service instance.

python
drive = gspace.drive()

sheets()

Get the Sheets service instance.

python
sheets = gspace.sheets()

docs()

Get the Docs service instance.

python
docs = gspace.docs()

Other Methods

close()

Close the client and clean up resources.

python
gspace.close()