qmetrics.net

Apps Script OAuth2

OAuth2 client library for Google Apps Script projects

Apps Script OAuth2 screenshot

This library creates and refreshes OAuth2 tokens inside Apps Script, routing user authorization through the platform usercallback endpoint.

Overview

OAuth2 for Apps Script is a library published for Google Apps Script projects that need to authorize against external OAuth2 providers. It wraps creation of authorization URLs, callback handling, access-token retrieval, refresh, and logout reset in a service object you configure per provider.

Redirects use Apps Script StateTokenBuilder and the standard usercallback URL format tied to your script ID, which you register as the redirect URI with the provider. Many Google APIs may be reachable through built-in or advanced Apps Script services without this library, using ScriptApp.getOAuthToken instead.

Typical usage builds a private OAuth2Service with endpoints and client credentials, sends the user to getAuthorizationUrl, handles handleCallback in a web callback, then attaches the bearer token to UrlFetchApp requests. Token persistence uses PropertiesService or CacheService with optional LockService to avoid refresh races in add-ons.

Advanced configuration covers token payload formats, extra headers, non-POST token endpoints, custom payload handlers, service-account JWT flows including domain-wide delegation, and alternate grant types such as client credentials.

Key features

  • OAuth2 authorization URL generation
  • Apps Script usercallback redirect handling
  • Access token refresh and reset
  • Properties and cache backed token storage
  • Locking around concurrent token refresh
  • Service account JWT authorization flow
  • Support for custom grant types and headers
  • Published Apps Script library distribution

Use cases

  • Third-party API access from Workspace automations
  • Add-on OAuth for non-Google providers
  • Service account calls with domain-wide delegation
  • Persisted tokens for scheduled script triggers

Tags

Similar software

n8n

Fair-code AI workflow and agent automation platform

n8n is a fair-code platform for building AI agents and automated workflows. It pairs a visual editor with custom code and links to many integrations.

★ 212.4k⟳ todaySource-available
Alternative to:IFTTTMake+2

CC Switch

Cross-platform desktop manager for AI coding agent tooling

CC Switch is a desktop application that switches API providers for Claude Code, Codex, OpenCode, and related coding tools. It centralizes MCP, Skills, and prompt configuration without hand-editing JSON, TOML, or YAML.

★ 157.6k⟳ todayMIT
Integration PlatformsDesktop/CLI app

CLIProxyAPI

Local proxy exposing CLI AI accounts as standard model APIs

Runs a local server that translates OpenAI-, Gemini-, Claude-, and Codex-compatible clients to OAuth-backed CLI provider accounts.

★ 59.6k⟳ todayMIT

Sub2API

Subscription quota gateway for AI model APIs

Sub2API is an AI API gateway that routes Claude, OpenAI, Gemini, and Grok subscription capacity through one relay. Clients can share quotas and use native tooling by changing the base URL.

★ 46.7k⟳ yesterdayLGPL-3.0

Hyperswitch

Composable open-source payments orchestration platform with modular components

Hyperswitch is an open-source Rust payments platform connecting many payment processors through one API. It offers routing, retries, vaulting, cost observability and reconciliation modules, and can be self-hosted or used as a hosted service

★ 45.9k⟳ todayApache-2.0

Magpie

Local gateway to switch AI coding agent models

magpie runs a local OpenAI, Anthropic, and Gemini-compatible gateway so many coding agents can share providers, subscriptions, and failover routing from a menu bar app or CLI.

★ 42.5k⟳ todayMIT
Integration PlatformsDesktop/CLI app