How aiocrafters/autoblog-python works
1. This repository is a small Python command-line automation tool, not a long-running service. Its architecture is a sequence of one-off scripts that interact with Google’s OAuth 2.0 and Blogger API v3.
2. The repo has three functional entry points:
- get_blogger_token.py for initial OAuth authorization and refresh-token acquisition
- get_blog_id.py for discovering available Blogger blogs and their IDs
- publish_post.py for creating Blogger posts or drafts
3. The main external boundary is Google’s cloud APIs. The project depends on:
- Google OAuth 2.0 for user authorization
- Blogger API v3 for blog discovery and post creation
- Google account permissions tied to the user’s Blogger blog
4. Configuration is separated from code through a .env file. The runtime credentials boundary is:
- GOOGLE_CLIENT_ID
- GOOGLE_CLIENT_SECRET
- GOOGLE_REFRESH_TOKEN
- BLOGGER_BLOG_ID
This keeps secrets out of the scripts and makes the tooling account-specific.
5. The authentication flow is two-stage. First, the user runs get_blogger_token.py to perform a browser-based OAuth consent flow. That script exchanges the initial authorization for a refresh token, which is then reused for future runs without prompting the browser again.
6. get_blog_id.py is a discovery tool. It uses the authenticated Google session to call the Blogger API and list blogs associated with the account, exposing the blog title, URL, and numeric blog ID. That ID becomes a required input for publishing.
7. publish_post.py is the write path. It constructs a Blogger post from locally defined content fields such as title, body, and draft/publish mode, then sends the create-post request to the Blogger API using the selected blog ID and stored refresh token.
8. The data flow is linear and manual:
- Google Cloud OAuth client credentials are created externally
- The token script produces a refresh token
- The blog-id script discovers the target blog ID
- The publish script sends content to that blog
Each step feeds the next through .env or copied values.
9. The repository’s Python dependency layer is thin and focused on Google integration:
- google-auth, google-auth-oauthlib, and google-auth-httplib2 handle OAuth and credential refresh
- google-api-python-client talks to Blogger API v3
- python-dotenv loads .env configuration into the scripts
10. There is no database, queue, or internal API server. State is mostly externalized in Google account credentials and the .env file, with the only durable outputs being the refresh token, the blog ID, and the published Blogger posts themselves.
11. The operational boundary is local machine execution. The scripts assume a desktop-style OAuth client and a user running them manually from a Python environment, typically with a virtualenv.
12. For an architecture diagram, the key components are: local Python scripts, .env configuration, Google OAuth 2.0, and Blogger API v3. The primary arrows are from scripts to Google auth, then from authenticated scripts to Blogger API, with discovered identifiers and tokens stored back into .env for reuse.
Main entry points: publish_post.py Publish post · get_blogger_token.py Get token · get_blog_id.py Get blog ID
Components 11
Local scripts
One-off Python entry points and local runtime inputs.
- Get token · Runs browser-based OAuth consent and captures a refresh token.
get_blogger_token.py - Get blog ID · Lists Blogger blogs for the authenticated account and surfaces the target blog ID.
get_blog_id.py - Publish post · Creates a Blogger post or draft for the selected blog.
publish_post.py - .env · Local credential and runtime settings boundary for account-specific values.
- Client ID · Google OAuth client identifier loaded from environment.
- Client secret · Google OAuth client secret loaded from environment.
- Refresh token · Reusable Google OAuth refresh token persisted for later runs.
- Blog ID · Selected Blogger blog identifier used when publishing.
Google services
External OAuth and Blogger API boundaries.
- OAuth 2.0 · Google authorization flow used to obtain and refresh credentials.
- Blogger API v3 · Google API for discovering blogs and creating posts.
- Google account · User-owned account that grants Blogger permissions.
Connections 14
- .env → Client ID: loads · Environment file provides OAuth client ID.
- .env → Client secret: loads · Environment file provides OAuth client secret.
- .env → Refresh token: loads · Environment file provides stored refresh token.
- .env → Blog ID: loads · Environment file provides selected blog ID.
- Get token → OAuth 2.0: authenticates · Initiates browser-based OAuth consent and token exchange.
- OAuth 2.0 → Google account: consents · User grants access to the Blogger-enabled Google account.
- Get token → Refresh token: writes · Produces a reusable refresh token for later runs.
- Get blog ID → OAuth 2.0: authenticates · Uses Google credentials to access Blogger discovery endpoints.
- Get blog ID → Blogger API v3: lists blogs · Fetches blogs associated with the authenticated account.
- Blogger API v3 → Blog ID: returns · Discovery response yields the numeric blog identifier.
- Publish post → Refresh token: uses · Refresh token is exchanged for access during publishing.
- Publish post → Blog ID: targets · Selected blog ID determines where the post is created.
- Publish post → Blogger API v3: creates post · Sends the post or draft creation request.
- Blogger API v3 → Google account: authorizes · Blogger enforces permissions tied to the Google account.