Skip to main content

gpsoauth

CI PyPI version repominder

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.

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.

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.

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. The page may show a loading screen forever; ignore it and move on to the next step.
  4. Obtain the value of the oauth_token cookie. For more details see the gpsoauth-java readme.

Then, perform the token exchange:

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

Contributing

See Contributing guidelines. This is an open-source project and all contributions are highly welcomed.

Metadata

Release files for gpsoauth 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gpsoauth 2.0.0
File Size Uploaded
gpsoauth-2.0.0.tar.gz 6.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gpsoauth 2.0.0
File Interpreter ABI Platform
gpsoauth-2.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 13.9 kB

Release files / gpsoauth-2.0.0.tar.gz

Download URL gpsoauth-2.0.0.tar.gz
Size 6.5 kB
Tags Source
SHA-256 checksum
How to use checksums
9e3b765a6a4e0364dec1bc4157bd3ed7e5ec3066589e285d0b46986910aa6bd2
BLAKE2b-256 checksum
How to use checksums
1a6af4fd84bcfd513d512711a2a14039ac431201c440c29a8f76af5584a34614
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.20

Release files / gpsoauth-2.0.0-py3-none-any.whl

Download URL gpsoauth-2.0.0-py3-none-any.whl
Size 7.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fb8bf9cb8b6e6bee1dbedbbbe8958ace71cddaccf5950e79b38c4d2ae9870641
BLAKE2b-256 checksum
How to use checksums
fe7a1dc1e06235732d1a1037640ec6aabd8fc18597a909848885376f1a0cffe3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.20

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.4.3

1 release file

0.4.2

1 release file

0.4.1

1 release file

0.4.0

1 release file

0.3.0

1 release file

0.2.0

1 release file

0.1.0

1 release file

0.0.5

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page