# gpsoauth
[![CI](https://github.com/simon-weber/gpsoauth/actions/workflows/ci.yaml/badge.svg)](https://github.com/simon-weber/gpsoauth/actions/workflows/ci.yaml)
[![PyPI version](https://badge.fury.io/py/gpsoauth.svg)](https://pypi.org/project/gpsoauth/)
[![repominder](https://img.shields.io/badge/dynamic/json.svg?label=release&query=%24.status&maxAge=43200&uri=https%3A%2F%2Fwww.repominder.com%2Fbadge%2FeyJmdWxsX25hbWUiOiAic2ltb24td2ViZXIvZ3Bzb2F1dGgifQ%3D%3D%2F&link=https%3A%2F%2Fwww.repominder.com%2F)](https://www.repominder.com)
**Python client library for Google Play Services OAuth.**
`gpsoauth` allows python code to use the "master token" flow that KB Sriram described at
<http://sbktech.blogspot.com/2014/01/inside-android-play-services-magic.html>.
```python
import gpsoauth
email = 'example@gmail.com'
password = 'my-password'
android_id = '0123456789abcdef'
master_response = gpsoauth.perform_master_login(email, password, android_id)
master_token = master_response['Token']
auth_response = gpsoauth.perform_oauth(
email, master_token, android_id,
service='sj', app='com.google.android.music',
client_sig='...')
token = auth_response['Auth']
```
This can be useful when writing code that poses as a Google app, like
[gmusicapi does here](https://github.com/simon-weber/gmusicapi/blob/87a802ab3a59a7fa2974fd9755d59a55275484d9/gmusicapi/session.py#L267-L278).
Many thanks to Dima Kovalenko for reverse engineering the EncryptedPasswd signature in
<https://web.archive.org/web/20150814054004/http://codedigging.com/blog/2014-06-09-about-encryptedpasswd/>.
For an explanation of recent changes, see [the changelog](https://github.com/simon-weber/gpsoauth/blob/master/CHANGELOG.md).
## Alternative flow
There is an alternative login flow if you are experiencing `BadAuthentication` errors.
1. Go to https://accounts.google.com/EmbeddedSetup
2. Log into your Google Account
3. Click on "I agree" when prompted
4. Obtain the value of the `oauth_token` cookie. For more details see [the gpsoauth-java readme](https://github.com/rukins/gpsoauth-java/blob/b74ebca999d0f5bd38a2eafe3c0d50be552f6385/README.md#receiving-an-authentication-token).
Then, perform the token exchange:
```python
import gpsoauth
email = 'example@gmail.com'
android_id = '0123456789abcdef'
token = '...' # insert the oauth_token here
master_response = gpsoauth.exchange_token(email, token, android_id)
master_token = master_response['Token'] # if there's no token check the response for more details
auth_response = gpsoauth.perform_oauth(
email, master_token, android_id,
service='sj', app='com.google.android.music',
client_sig='...')
token = auth_response['Auth']
```
## Ports
- C\#: <https://github.com/vemacs/GPSOAuthSharp>
- Ruby: <https://github.com/bryanmytko/gpsoauth>
- Java: <https://github.com/svarzee/gpsoauth-java>
- C++: <https://github.com/dvirtz/gpsoauth-cpp> and <https://github.com/Iciclelz/gpsoauthclient>
## Contributing
See [Contributing guidelines](https://github.com/simon-weber/gpsoauth/blob/master/CONTRIBUTING.md).
This is an open-source project and all contributions are highly welcomed.
Raw data
{
"_id": null,
"home_page": "https://github.com/simon-weber/gpsoauth",
"name": "gpsoauth",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.8",
"maintainer_email": null,
"keywords": null,
"author": "Simon Weber",
"author_email": "simon@simonmweber.com",
"download_url": "https://files.pythonhosted.org/packages/8c/b3/3494be6889ba70c17dc478a94c096ed891458f8ed10ca6ebc66ba1963764/gpsoauth-1.1.1.tar.gz",
"platform": null,
"description": "# gpsoauth\n\n[![CI](https://github.com/simon-weber/gpsoauth/actions/workflows/ci.yaml/badge.svg)](https://github.com/simon-weber/gpsoauth/actions/workflows/ci.yaml)\n[![PyPI version](https://badge.fury.io/py/gpsoauth.svg)](https://pypi.org/project/gpsoauth/)\n[![repominder](https://img.shields.io/badge/dynamic/json.svg?label=release&query=%24.status&maxAge=43200&uri=https%3A%2F%2Fwww.repominder.com%2Fbadge%2FeyJmdWxsX25hbWUiOiAic2ltb24td2ViZXIvZ3Bzb2F1dGgifQ%3D%3D%2F&link=https%3A%2F%2Fwww.repominder.com%2F)](https://www.repominder.com)\n\n**Python client library for Google Play Services OAuth.**\n\n`gpsoauth` allows python code to use the \"master token\" flow that KB Sriram described at\n<http://sbktech.blogspot.com/2014/01/inside-android-play-services-magic.html>.\n\n```python\nimport gpsoauth\n\nemail = 'example@gmail.com'\npassword = 'my-password'\nandroid_id = '0123456789abcdef'\n\nmaster_response = gpsoauth.perform_master_login(email, password, android_id)\nmaster_token = master_response['Token']\n\nauth_response = gpsoauth.perform_oauth(\n email, master_token, android_id,\n service='sj', app='com.google.android.music',\n client_sig='...')\ntoken = auth_response['Auth']\n```\n\nThis can be useful when writing code that poses as a Google app, like\n[gmusicapi does here](https://github.com/simon-weber/gmusicapi/blob/87a802ab3a59a7fa2974fd9755d59a55275484d9/gmusicapi/session.py#L267-L278).\n\nMany thanks to Dima Kovalenko for reverse engineering the EncryptedPasswd signature in\n<https://web.archive.org/web/20150814054004/http://codedigging.com/blog/2014-06-09-about-encryptedpasswd/>.\n\nFor an explanation of recent changes, see [the changelog](https://github.com/simon-weber/gpsoauth/blob/master/CHANGELOG.md).\n\n## Alternative flow\n\nThere is an alternative login flow if you are experiencing `BadAuthentication` errors.\n\n1. Go to https://accounts.google.com/EmbeddedSetup\n2. Log into your Google Account\n3. Click on \"I agree\" when prompted\n4. Obtain the value of the `oauth_token` cookie. For more details see [the gpsoauth-java readme](https://github.com/rukins/gpsoauth-java/blob/b74ebca999d0f5bd38a2eafe3c0d50be552f6385/README.md#receiving-an-authentication-token).\n\nThen, perform the token exchange:\n\n```python\nimport gpsoauth\n\nemail = 'example@gmail.com'\nandroid_id = '0123456789abcdef'\ntoken = '...' # insert the oauth_token here\n\nmaster_response = gpsoauth.exchange_token(email, token, android_id)\nmaster_token = master_response['Token'] # if there's no token check the response for more details\n\nauth_response = gpsoauth.perform_oauth(\n email, master_token, android_id,\n service='sj', app='com.google.android.music',\n client_sig='...')\ntoken = auth_response['Auth']\n```\n\n## Ports\n\n- C\\#: <https://github.com/vemacs/GPSOAuthSharp>\n- Ruby: <https://github.com/bryanmytko/gpsoauth>\n- Java: <https://github.com/svarzee/gpsoauth-java>\n- C++: <https://github.com/dvirtz/gpsoauth-cpp> and <https://github.com/Iciclelz/gpsoauthclient>\n\n## Contributing\n\nSee [Contributing guidelines](https://github.com/simon-weber/gpsoauth/blob/master/CONTRIBUTING.md).\nThis is an open-source project and all contributions are highly welcomed.\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A python client library for Google Play Services OAuth.",
"version": "1.1.1",
"project_urls": {
"Homepage": "https://github.com/simon-weber/gpsoauth",
"Repository": "https://github.com/simon-weber/gpsoauth"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "7bad89f0921a402cdaf715ecb9d3b8509a6a71999b01eb471f60553bf5d4e926",
"md5": "21b5487ed8688d0c6fb41b77f01c7d6e",
"sha256": "0fa7959b1d52fc625d93928e4ad4349ac79c6bfe811981d4f91f3b687e1b6fc1"
},
"downloads": -1,
"filename": "gpsoauth-1.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "21b5487ed8688d0c6fb41b77f01c7d6e",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.8",
"size": 7300,
"upload_time": "2024-06-10T01:20:28",
"upload_time_iso_8601": "2024-06-10T01:20:28.228632Z",
"url": "https://files.pythonhosted.org/packages/7b/ad/89f0921a402cdaf715ecb9d3b8509a6a71999b01eb471f60553bf5d4e926/gpsoauth-1.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "8cb33494be6889ba70c17dc478a94c096ed891458f8ed10ca6ebc66ba1963764",
"md5": "9916ed1b60fc9ad827c04de0e8c2d380",
"sha256": "58202ed303397d2927b464dc95e2714bffff85a1b0f88bf68f3ad63859ebe435"
},
"downloads": -1,
"filename": "gpsoauth-1.1.1.tar.gz",
"has_sig": false,
"md5_digest": "9916ed1b60fc9ad827c04de0e8c2d380",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.8",
"size": 6627,
"upload_time": "2024-06-10T01:20:29",
"upload_time_iso_8601": "2024-06-10T01:20:29.600265Z",
"url": "https://files.pythonhosted.org/packages/8c/b3/3494be6889ba70c17dc478a94c096ed891458f8ed10ca6ebc66ba1963764/gpsoauth-1.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-06-10 01:20:29",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "simon-weber",
"github_project": "gpsoauth",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "gpsoauth"
}