google-oauth-file-poll
Skill2 starsChanged 2 months agoMITView on GitHub
Use when Google API OAuth needs a headless file-poll flow.
In this repository58 other files it gives its agents.
- ad-hoc-script-verificationSkill
- architecture-diagramSkill
- blocked-page-recoverySkill
- cadquery-enclosure-designSkill
- canonical-thumbnailSkill
- circuit-designSkill
- competitor-news-monitorSkill
- component-alternativesSkill
- debugging-hermes-tui-commandsSkill
- docker-container-update-checkSkill
- document-to-action-itemsSkill
- docxSkill
- email-inbox-triageSkill
- embedded-porting-patternsSkill
- ephemeral-file-sharingSkill
- excalidrawSkill
- flash-game-researchSkill
- flutter-android-buildSkill
- flutter-content-renderingSkill
- github-code-reviewSkill
- githubSkill
- goatcounter-analyticsSkill
- grounded-citationsSkill
- hermes-agent-skill-authoringSkill
- hermes-gateway-slash-commandSkill
- hermes-gateway-supervisionSkill
- jellyseerr-watch-suggestionsSkill
- maintained-fork-publishingSkill
- meeting-action-itemsSkill
- native-mcpSkill
- obsidian-mapsSkill
- pdf-flattenSkill
- pdfSkill
- pdf-surgical-editsSkill
- planSkill
- product-price-monitorSkill
- psp-developmentSkill
- psp-homebrew-testingSkill
- psp-prx-plugin-maintenanceSkill
- python-debugpySkill
- python-webapp-patternsSkill
- reddit-readingSkill
- retro-fansiteSkill
- reverse-proxy-websocket-debuggingSkill
- rss-feedsSkill
- simplify-codeSkill
- sketchSkill
- skit-thumbnailSkill
- spikeSkill
- subagent-driven-developmentSkill
- test-driven-developmentSkill
- usb-device-enumerationSkill
- weekly-review-planningSkill
- wiki-media-asset-pipelineSkill
- windows-c-build-toolchainSkill
- windows-crash-forensicsSkill
- writing-plansSkill
- yt-dlp-anti-botSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 40
Run the script: it builds an InstalledAppFlow, sets the out-of-band redirect URI (urn:ietf:wg:oauth:2.0:oob), writes auth_url.txt, and …
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Google API OAuth: Headless File-Poll Flow
Overview
Authorize Google API clients (YouTube, Drive, Gmail, Sheets, …) on machines with no browser: a script writes the consent URL to a file, the user opens it on ANY device, pastes the code into another file, and the script polls until it arrives, then stores the refreshable token. No browser on the box, no port forwarding, no interactive prompts. Works identically on headless servers, CI runners, and USB-portable environments.
Ships scripts/oauth_file_poll.py — a complete, configurable implementation.
When to Use
- Automating Google APIs from servers/containers without a display.
- Recurring upload/new-scope automation where the token expires and the re-auth dance happens repeatedly.
- Don't use for: interactive local development where a browser is fine —
InstalledAppFlow.run_local_server()is easier there.
The Flow
- Have a Google Cloud OAuth desktop client (
client_secret.json) with the needed scopes enabled. - Run the script: it builds an
InstalledAppFlow, sets the out-of-band redirect URI (urn:ietf:wg:oauth:2.0:oob), writesauth_url.txt, and prints the path. No browser is opened. - The user opens the URL anywhere (phone/laptop), consents, and pastes the
code into
auth_code.txt. - The script polls
auth_code.txt(default 600s), exchanges the code, savestoken.json, and deletes both temp files. - Next runs reuse
token.jsonand refresh automatically when expired:
from google.oauth2.credentials import Credentials
from google.auth.transport.requests import Request
creds = Credentials.from_authorized_user_file("token.json", SCOPES)
if creds.expired and creds.refresh_token:
creds.refresh(Request())Then build the API service: googleapiclient.discovery.build("youtube", "v3", credentials=creds).
Script Configuration
Edit the top of scripts/oauth_file_poll.py:
CLIENT_SECRET/TOKEN_FILE— paths (keep OUT of version control).SCOPES— the exact scopes for the API you automate.TIMEOUT— seconds to wait for the paste-back code (default 600).
Common Pitfalls
- PKCE handshake is finicky across separate processes — run the generate/URL + poll + exchange in ONE long-lived script, not in separate invocations with hand-carried state.
oobredirect deprecation — some client types rejectoob; if so, use a loopback redirect and read the code from the localhost URL.- Never commit
token.json/client_secret.json— add both to.gitignore; a leaked client secret lets anyone mint tokens. - Expired refresh flow — a token whose refresh token is gone (revoked consent, scope change) requires a full re-consent; detect and restart the file-poll flow instead of erroring.
- Timeout hygiene — always clean up
auth_url.txt/auth_code.txton success and on timeout; stale code files break the next attempt.
Verification Checklist
- First run writes
auth_url.txtand prints its path - After code paste,
token.jsonexists and temp files are deleted - A second run completes WITHOUT prompting (token reuse/refresh)
- API call succeeds with the stored credentials
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

