Skip to main content

gpsoauth compatibility layer for google-api-python-client

Project description

GPSOauth Compatibility Layer

gpsoauth compatibility layer for google-api-python-client

Use Google Play Services authentication provided by gpsoauth with public Google APIs provided by google-api-python-client.

Google Play Services authenticated accounts are sometimes given special permissions, even on public APIs. This project thus aims to reduce the need for maintaining scattered wrappers around privileged private APIs when public APIs give the same privileges with gpsoauth-provided tokens.

This mini-library aims to pose as the many Android apps that Google allows access to its API. Unfortunately, not all API scopes are available for consumption on Android applications. A comprehensive list of unavailable scopes is being worked on. In the meantime, consider using Google's recommended flow of authentication for the scopes that are unavailable on any of Google's Android applications.

Usage

See https://github.com/rukins/gpsoauth-java#receiving-an-authentication-token for obtaining your account's oauth token.

from googleapiclient.discovery import build
from gpsoauth_compat import GPLogin

SCOPES = ['https://www.googleapis.com/auth/drive.metadata.readonly']
API_SERVICE_NAME = 'drive'
API_VERSION = 'v3'

OAUTH_TOKEN = 'SECRET_GOES_HERE'

flow = GPLogin.from_oauth_token(OAUTH_TOKEN, SCOPES)
# alternatively use the following line if you already have authenticated before
# flow = GPLogin.from_master_token(MASTER_TOKEN, SCOPES)

credentials = flow.credentials
service = build(API_SERVICE_NAME, API_VERSION, credentials = credentials)
print(service.files().list().execute())

[!WARNING] To log-out and disable this token and all its derivatives, visit https://myaccount.google.com/device-activity and navigate to your desired account. From there, you will find a device with a small caption on it saying "Android device". Click on it and log out from it.

It may be associated with your browser's login session, so you will have to use a private/ incognito browsing session to access that webpage and log yourself out from your main browser. You may have to log in into your main browser again to continue using your account on it.

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_compat-0.1.0rc1.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gpsoauth_compat-0.1.0rc1-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file gpsoauth_compat-0.1.0rc1.tar.gz.

File metadata

  • Download URL: gpsoauth_compat-0.1.0rc1.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.12.6 Windows/11

File hashes

Hashes for gpsoauth_compat-0.1.0rc1.tar.gz
Algorithm Hash digest
SHA256 5806ca412de0d9fc299d708ef4d9be05d5348cbf8ff069e0af64a170d5ea5dd5
MD5 89dbc87ccda237e99b636efe30844c93
BLAKE2b-256 a0f42876cd2b78f9286e5b02dd05c5999e26e29c341a72227b994bc5352f110f

See more details on using hashes here.

File details

Details for the file gpsoauth_compat-0.1.0rc1-py3-none-any.whl.

File metadata

File hashes

Hashes for gpsoauth_compat-0.1.0rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 ce43c3d3280d2e283e4155e435e570483df31ac78a956c0892940b1bd7a97a09
MD5 40be101556f6697bb32a7531ed2a41c2
BLAKE2b-256 793731bc7de69ca335f837b7f69019e58eab47e8e489ee453064b5cb798252c7

See more details on using hashes here.

Supported by

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