{"id":13585957,"url":"https://github.com/leikoilja/glocaltokens","last_synced_at":"2025-04-04T13:09:31.873Z","repository":{"id":37010470,"uuid":"325310899","full_name":"leikoilja/glocaltokens","owner":"leikoilja","description":"Python 3 package to fetch google home local authentication tokens and IP using google username/password or google master token","archived":false,"fork":false,"pushed_at":"2024-10-28T12:44:03.000Z","size":1264,"stargazers_count":48,"open_issues_count":8,"forks_count":11,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-10-30T01:59:02.211Z","etag":null,"topics":["google-home","google-token","homeassistant","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leikoilja.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-12-29T14:42:17.000Z","updated_at":"2024-10-28T12:44:06.000Z","dependencies_parsed_at":"2023-02-19T08:45:30.756Z","dependency_job_id":"7160fa8e-58ca-4b0b-a2b6-c6c2f8a1058d","html_url":"https://github.com/leikoilja/glocaltokens","commit_stats":{"total_commits":490,"total_committers":8,"mean_commits":61.25,"dds":"0.24081632653061225","last_synced_commit":"1e0f7130d41a17ad538f05a991fff472993d5e04"},"previous_names":[],"tags_count":34,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leikoilja%2Fglocaltokens","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leikoilja%2Fglocaltokens/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leikoilja%2Fglocaltokens/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leikoilja%2Fglocaltokens/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leikoilja","download_url":"https://codeload.github.com/leikoilja/glocaltokens/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247182344,"owners_count":20897379,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["google-home","google-token","homeassistant","python"],"created_at":"2024-08-01T15:05:14.767Z","updated_at":"2025-04-04T13:09:31.848Z","avatar_url":"https://github.com/leikoilja.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"[![GitHub Workflow Status][workflow-shield]][workflow]\n[![PyPI][pypi-shield]][pypi]\n[![Downloads][pepy-shield]][pepy]\n[![Pre-commit][pre-commit-shield]][pre-commit]\n[![GitHub Activity][commits-shield]][commits]\n\n# Google home local authentication token extraction\n\nPython 3 package to extract google home devices local authentication tokens from google servers.\nThese local authentication tokens are needed to control Google Home devices\n(See [@rithvikvibhu](https://github.com/rithvikvibhu)'s [Google Home (2.0) API](https://rithvikvibhu.github.io/GHLocalApi/)).\n\nPlease note:\nOnce you have local google authentication tokens they only live about 1 day long.\nAfter that you will need to obtain new ones.\nYou will probably need to run the script repeatedly storing the tokens somewhere convenient.\n\n## Quickstart\n\nNote: the package was written and tested on Python 3.\n\n- Install the python package.\n\nUsing uv:\n\n```console\n$ uv add glocaltokens\n```\n\nUsing pip:\n\n```console\n$ pip install glocaltokens\n```\n\nUse in your program as (see examples folder for detailed example):\n\n```Python\nfrom glocaltokens.client import GLocalAuthenticationTokens\n\n# Using google username and password\n#\n# ONLY CALL THIS ONCE\n#\n# If you call this too often, google will disconnect your android devices and other weird things will happen\n#\n# Call get_google_devices_json() afterwards to get timers/alarms as oftens as you want to update.\nclient = GLocalAuthenticationTokens(\n  username=\"\u003cYOUR_GOOGLE_USERNAME\u003e\",\n  password=\"\u003cYOUR_GOOGLE_PASSWORD\u003e\"\n)\n\n# Get master token\nprint(\"[*] Master token\", client.get_master_token())\n\n# Get access token (lives 1 hour)\nprint(\"\\n[*] Access token (lives 1 hour)\", client.get_access_token())\n\n# Get google device local authentication tokens (live about 1 day)\nprint(\"\\n[*] Google devices local authentication tokens\")\ngoogle_devices = client.get_google_devices_json()\n\n# You can also select specific models to select when calling get_google_devices or get_google_devices_json with the models_list parameter.\n# For example, we have pre-defined a constant with some Google Home Models (WARNING! Not all of them may be present)\n# This could be used this way\nfrom glocaltokens.const import GOOGLE_HOME_MODELS\n\ngoogle_devices_select = client.get_google_devices_json(GOOGLE_HOME_MODELS)\n\n# But if you need to select just a set of models, or add new models, you can use a list of str\ngoogle_devices_select_2 = client.get_google_devices_json([\n    f\"Google Home\",\n    f\"Google Home Mini\",\n    f\"Google Nest Mini\",\n])\n```\n\n### Predefined models list\n\nThere are some pre-defined models list in [`scanner.py`](/glocaltokens/scanner.py), feel free to\nadd new lists, or add models to a list with a pull-request.\n\n#### `GOOGLE_HOME_MODELS`:\n\n- Google Home\n- Google Home Mini\n- Google Nest Mini\n- Lenovo Smart Clock\n\n## Security Recommendation\n\nNever store the user's password nor username in plain text, if storage is necessary, generate a master token and store it.\nExample approach:\n\n```python\nfrom glocaltokens.client import GLocalAuthenticationTokens\n\n# Using google username and password first, and only once\nclient = GLocalAuthenticationTokens(\n  username=\"\u003cYOUR_GOOGLE_USERNAME\u003e\",\n  password=\"\u003cYOUR_GOOGLE_PASSWORD\u003e\"\n)\n\n# Get master token\nmaster_token = client.get_master_token()\nprint(\"[*] Master token\", master_token)\n\n\"\"\"Now store master_token somewhere\"\"\"\n\n```\n\n## Contributing\n\nSee [Contributing guidelines](CONTRIBUTING.md).\nThis is an open-source project and all countribution is highly welcomed.\n\n# Credits\n\nMuch credits go to [@rithvikvibhu](https://github.com/rithvikvibhu) for doing most of the heavy work like finding a way to\nextract master and access tokens\n(See his gist [here](https://gist.github.com/rithvikvibhu/952f83ea656c6782fbd0f1645059055d)).\n\nAlso, thank you very much to the guys at `pychromecast` which provided the code required to scan devices in the network.\n\n[workflow-shield]: https://img.shields.io/github/actions/workflow/status/leikoilja/glocaltokens/linting-and-testing.yaml?branch=master\n[workflow]: https://github.com/leikoilja/glocaltokens/actions\n[pypi-shield]: https://img.shields.io/pypi/v/glocaltokens\n[pypi]: https://pypi.org/project/glocaltokens/\n[pepy-shield]: https://pepy.tech/badge/glocaltokens\n[pepy]: https://pepy.tech/project/glocaltokens\n[commits-shield]: https://img.shields.io/github/commit-activity/y/leikoilja/glocaltokens\n[commits]: https://github.com/leikoilja/glocaltokens/commits/master\n[pre-commit-shield]: https://img.shields.io/badge/pre--commit-enabled-brightgreen\n[pre-commit]: https://pre-commit.com/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleikoilja%2Fglocaltokens","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleikoilja%2Fglocaltokens","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleikoilja%2Fglocaltokens/lists"}