Skip to main content

A data scientist's toolbox for Google Suite Apps

Project description

pysuite: A data scientist's toolbox for Google Suite App

PyPI version codecov PyPI - Downloads

A python wrapper for Google Suite and Google Cloud Service API. This provides classes with user-friendly apis to operate with several Google API services. Currently, the supported services are:

For details on how to use pysuite, please view the documentation page

Get credentials

Credential files are necessary to access all Google Services supported in pysuite. There are two categories. Each requires its own credential file.

  • Google Suite: This includes Google Drive, Gmail and Spreadsheet.
  • Google Cloud: This includes Google Vision and Cloud Storage

Google Suite

You need to get a credential from Google API Console. The credential looks like:

{
  "installed": {
    "client_id": "xxxxxxxxxxxxxxxxx.apps.googleusercontent.com",
    "project_id": "xxxxxxxxxxxxx-xxxxxxxxxxxx",
    "auth_uri": "https://accounts.google.com/o/oauth2/auth",
    "token_uri": "https://oauth2.googleapis.com/token",
    "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
    "client_secret": "xxxxxxxxxxxxxxxx",
    "redirect_uris": [
      "urn:ietf:wg:oauth:2.0:oob",
      "http://localhost"
    ]
  }
}

You can also provide a token json file if possible, the token file looks like:

{
     "token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
     "refresh_token": "xxxxxxxxx"
}

If token file doesn't exist, a confirmation is needed from browser prompt. Then the token file will be created.

from pysuite import Authentication

credential_json_file = "/tmp/credential.json"
token_path_file = "/tmp/token.json"
client = Authentication(credential=credential_json_file, token=token_path_file, services="sheets")

Google Cloud Service

You need to get a credential json from Google Cloud. The credential looks like:

{
  "type": "service_account",
  "project_id": "your_project_id",
  "private_key_id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "private_key": "-----BEGIN PRIVATE KEY-----xxxxxxxxxxx-----END PRIVATE KEY-----\n",
  "client_email": "some@email.address",
  "client_id": "xxxxxxxxxxxxxxxx",
  "auth_uri": "https://accounts.google.com/o/oauth2/auth",
  "token_uri": "https://oauth2.googleapis.com/token",
  "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
  "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/xxxxxxxxx"
}

You can use Authentication class similarly. Note that token file is not needed for Cloud Service.

from pysuite import Authentication

credential_json_file = "/tmp/credential.json"
client = Authentication(credential=credential_json_file, token=None, services=["storage", "vision"])

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

pysuite-0.4.0.tar.gz (18.0 kB view hashes)

Uploaded Source

Built Distribution

pysuite-0.4.0-py3-none-any.whl (20.2 kB view hashes)

Uploaded Python 3

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