Jae Wilson @DataCrew

DomoLibrary_Extensions - Google Drive APIs Class - using Inheritance

January 15, 2025

Hook (1-2 sentences): Every time you wrap a third-party API, you're making a choice: expose the raw library or build a consistent interface your team can actually predict. This video walks through how to design a Python class around Google's google-api-python-client so that every tool you build on top of it shares the same handwriting.

Why It Matters

Without an abstraction layer, every developer who touches your Google Drive integration has to learn Google's SDK conventions from scratch — token paths, scope lists, credential classes, and refresh logic. That cognitive overhead compounds across teammates and projects. By wrapping google-api-python-client in an inheritance-based class, you establish a single contract: one way to authenticate, one way to call the API, one pattern to debug. New tools inherit behavior instead of reinventing it.

What You'll Learn

  • Understand why wrapping google-api-python-client with inheritance creates a reusable, predictable interface
  • Build a generate_creds_from_file root function that reads OAuth2 tokens from a local JSON file
  • Wire up authorized_user_file to return a live Credentials instance with the right scopes
  • Handle token expiration gracefully so Python can authenticate as a user across sessions
  • Structure a class so teammates can make assumptions about how it behaves without reading the source