Skip to main content

A python client library for Google Play Services OAuth.

Project description

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
  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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gpsoauth-1.1.1.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

gpsoauth-1.1.1-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file gpsoauth-1.1.1.tar.gz.

File metadata

  • Download URL: gpsoauth-1.1.1.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.7

File hashes

Hashes for gpsoauth-1.1.1.tar.gz
Algorithm Hash digest
SHA256 58202ed303397d2927b464dc95e2714bffff85a1b0f88bf68f3ad63859ebe435
MD5 9916ed1b60fc9ad827c04de0e8c2d380
BLAKE2b-256 8cb33494be6889ba70c17dc478a94c096ed891458f8ed10ca6ebc66ba1963764

See more details on using hashes here.

File details

Details for the file gpsoauth-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: gpsoauth-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.7

File hashes

Hashes for gpsoauth-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0fa7959b1d52fc625d93928e4ad4349ac79c6bfe811981d4f91f3b687e1b6fc1
MD5 21b5487ed8688d0c6fb41b77f01c7d6e
BLAKE2b-256 7bad89f0921a402cdaf715ecb9d3b8509a6a71999b01eb471f60553bf5d4e926

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page