Install & Compatibility
Where this runs
tested against v0.7.6 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 59.1MB
glibcpy 3.10–3.910 runs
installs and imports cleanly · install 5.3s · import 0.000s · 58MB
57MB installed
● package 57MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
GlocalTokens
✓ import glocaltokens
✗ from glocaltokens import GlocalTokens
This quickstart demonstrates how to instantiate GlocalTokens, obtain a master token using environment variables for credentials, and print it. It includes basic error handling for authentication failures and advises on 2FA. Obtaining device-specific tokens requires additional setup and discovery (commented out).
import os
from glocaltokens import GlocalTokens, BadAuthenticationError
USERNAME = os.environ.get('GOOGLE_USERNAME', '')
PASSWORD = os.environ.get('GOOGLE_PASSWORD', '')
if not USERNAME or not PASSWORD:
print("Please set GOOGLE_USERNAME and GOOGLE_PASSWORD environment variables.")
else:
try:
gt = GlocalTokens(USERNAME, PASSWORD)
master_token = gt.get_master_token()
print(f"Master Token: {master_token}")
# Example: Get device tokens (requires a device to be connected/discovered)
# device_tokens = gt.get_device_tokens()
# print(f"Device Tokens: {device_tokens}")
except BadAuthenticationError as e:
print(f"Authentication failed: {e}")
print("Ensure 2-Factor Authentication is enabled for your Google account.")
except Exception as e:
print(f"An unexpected error occurred: {e}")
Debug
Known issues
breakingThe library's internal dependencies, particularly `gpsoauth` and `ghome-foyer-api` (which wraps `protobuf`), have seen significant version bumps. Upgrading `glocaltokens` may require a fresh environment or careful dependency resolution to avoid conflicts with other libraries using older `gpsoauth` or `protobuf` versions.fixUse a dedicated virtual environment. If protobuf conflicts persist, ensure no other packages pin a conflicting protobuf version. Consider using `pip install --no-deps glocaltokens` and manually installing compatible versions of `gpsoauth` and `ghome-foyer-api` if advanced control is needed, though this is rarely necessary.
affects: >=0.7.0 (protobuf changes), >=0.7.6 (gpsoauth 2.0.0)
gotchaAs of v0.6.9, `glocaltokens` requires Python 3.9 or higher. Attempts to install or run the library on older Python versions will fail.fixEnsure your Python environment is version 3.9 or newer. Upgrade Python if necessary or switch to a compatible virtual environment.
affects: >=0.6.9
gotchaGoogle accounts used for authentication generally require 2-Factor Authentication (2FA) to be enabled for `get_master_token()` to succeed, especially in headless or automated environments. Without 2FA, you might encounter `BadAuthenticationError`.fixEnable 2-Factor Authentication on the Google account you are using. This typically involves setting up a phone or authenticator app. Ensure the username and password are correct.
affects: All versions
Upgrade
Version history
0.7.6latest on PyPI · released Jul 4, 2025
Audit
Dependencies
gpsoauthrequiredRequired for Google Play Services authentication to obtain master tokens.
ghome-foyer-apirequiredHandles protobuf definitions and API interactions for Google Home devices.
protobufrequiredIndirectly required by ghome-foyer-api; version compatibility is crucial.