Skip to main content

Python Library for helping to create Python services from Google APIs

Something I have to do a lot is create connections to Google Service endpoints. This generally requires a fair amount of boiler-plate code that io just copied and pasted from other locations. Also any time a new service is needed, I need to find that specific implementation of the service builder and add the new endpoint.

Obviously this can lead to potential errors and if a bug is found, I have to remember where I created these services and fix it in many projects.

This has led me to create a small helper library to make the process easier. Included in the library is a complete and updated (at time of publishing) list of all the Google APIs along with their versions and endpoints as Enums ready for use.

Usage

service_builder.build_service() needs two mandatory pieces of information:

Parameter Type Description
key str The credentials to use to authenticate the user to the service it has to create.
service Service The Google API endpoint it is trying to connect to.
api_key See below Optional An API key for those services which require an API key in addition to credentials.
extra_scopes List[str] Optional Extra OAuth scopes needed.

key

These can be supplied in one of 4 ways.

  1. A valid google.oauth2.Credentials object, created and passed to the service builder.
  2. A str which is the name of a local file containing the json representation of an OAuth credentials object.
  3. A Mapping object which is a json keyfile dict
  4. An OAuthKey object from this package, which is a dataclass object comprising of the minimum fields necessary to perform the OAuth connection.

service

This is an Enum in the service_framework.service module, which defines the Google service you're planning to connect to. All the standard Google services are included (as of the date listed in the Services.py file).

If a new service has been added but this library has yet to be updated, you can request it by using either Service('<UNLISTED SERVICE>') or Service.from_value('<UNLISTED SERVICE>'). This will cause the library to attempt to fetch the service's definition from Google and will create an entry in the enum for this new service.

Examples

1. Using Credentials

from service_framework.services import Service
from service_framework import service_builder
from google.oauth2 import credentials as oauth

credentials = oauth.Credentials(
   access_token="<YOUR ACCESS TOKEN>",
   refresh_token="<YOUR REFRESH TOKEN>",
   token_uri="https://oauth2.googleapis.com/token",
   client_id="<YOUR CLIENT ID>",
   client_secret="<YOUR CLIENT SECRET>"
)

service = service_builder.build_service(service=Service.CHAT, key=credentials)

2. Using an OAuthKey

from service_framework.services import Service
from service_framework import service_builder

key = service_builder.OAuthKey(
   access_token="<YOUR ACCESS TOKEN>",
   refresh_token="<YOUR REFRESH TOKEN>",
   token_uri="https://oauth2.googleapis.com/token",
   client_id="<YOUR CLIENT ID>",
   client_secret="<YOUR CLIENT SECRET>"
)

service = service_builder.build_service(service=Service.GMAIL, key=key)

Here, we are creating the key as an OAuthKey object as we have clearly got the tokens and client_[id|secret] from elsewhere. Creating the service is then as simple as invoking the service_builder.build_service method which will return you a service you can use.

Metadata

Release files for python-service-builder 2.4.2

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

Source distribution (sdist)

Source distribution for python-service-builder 2.4.2
File Size Uploaded
python_service_builder-2.4.2.tar.gz 18.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for python-service-builder 2.4.2
File Interpreter ABI Platform
python_service_builder-2.4.2-py3-none-any.whl Python 3 none any Details

Total release size: 41.1 kB

Release files / python_service_builder-2.4.2.tar.gz

Download URL python_service_builder-2.4.2.tar.gz
Size 18.9 kB
Tags Source
SHA-256 checksum
How to use checksums
a0c87df2e613d7c78b5d86a47470bf47739e2c2c4579b3c4264c8e0e2c7b79dc
BLAKE2b-256 checksum
How to use checksums
7aeafcc3a27d1672b403a4266271a0c4a84ba04dfe0118b1808913499a8c73c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 9, 2026.

Transparency log

Release files / python_service_builder-2.4.2-py3-none-any.whl

Download URL python_service_builder-2.4.2-py3-none-any.whl
Size 22.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
262cc2bac5efdbef1a783f0089a8f57dadf0a1f791dcb666e56a482b1baffa8b
BLAKE2b-256 checksum
How to use checksums
7fbdc01c9a1519217ec9ff50cd5ce2fd345c3b02248d9d30423dbaadf5f37ead
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 9, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

2.4.2 This release

2 release files

2.4.1

2 release files

2.3.0

2 release files

2.2.0

2 release files

2.1.1

2 release files

2.1.0

2 release files

2.0.0

2 release files

1.3.0

2 release files

1.2.1

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.1.0

2 release files

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