apify-docs icon indicating copy to clipboard operation
apify-docs copied to clipboard

docs: add Python tutorial for refresh token OAuth in multi-tenant Apify Actors

Open foxck016077 opened this issue 6 months ago • 0 comments

Summary

Adds a new tutorial under sources/academy/tutorials/python/ covering the refresh token OAuth pattern for Apify Actors that call per-user Google APIs (Gmail, Calendar, Drive) without hosting an OAuth callback URL or storing user identity on the Apify side.

The tutorial walks through:

  1. Google Cloud setup using the Desktop app OAuth client type (which removes the redirect URL requirement)
  2. Generating the refresh token via google-auth-oauthlib's run_local_server flow
  3. Exchanging the refresh token for a short-lived access token at runtime
  4. Defining INPUT_SCHEMA with isSecret: true on the credential fields
  5. An optional dry_run boolean so first-time users can preview the dataset shape before committing to the full OAuth setup

Motivation

This pattern is used in production today for Actors that call per-user Google APIs, but the docs don't yet cover it. Currently a developer searching "Apify actor Gmail OAuth" finds no end-to-end tutorial. Related: apify/apify-mcp-server#741 asks for server-level OAuth/SSO between MCP client and Apify (a different layer than what this tutorial covers), but readers landing on that issue may also be looking for the Actor-level credential delegation pattern.

Pattern correctness

Verified against a production Actor running this exact pattern: foxck016077/apify-gmail-inbox-intel (MIT, listed on Apify Store as foxck/gmail-inbox-intel).

Standards checklist

  • [x] Sentence case headings, no gerund headings
  • [x] Front matter complete: title, description (154 chars), sidebar_position (3), slug
  • [x] Bold used only for UI elements (Apify Console buttons, Google Cloud sections)
  • [x] All code blocks have language tags (python, json)
  • [x] US English, active voice, imperative tone, no sales language
  • [x] No em dashes (hyphen with spaces only)
  • [x] Internal links use relative paths (e.g. /platform/actors/development/actor-definition/input-schema)
  • [x] No new images required

Compatibility

  • No changes to existing tutorials
  • New file only; no rename or move
  • sidebar_position: 3 slots after process_data_using_python.md (position 2)
  • Slug /python/refresh-token-oauth-multi-tenant-actors is unique

Happy to revise scope, tone, file placement, or pull cross-references if there's a better home for it in the Academy structure.

foxck016077 avatar May 20 '26 01:05 foxck016077