A Python tool to upload images to Google Blogger using the resumable upload API, authenticated via Google OAuth2.
- OAuth2 authentication with automatic token refresh
- Resumable image upload to Blogger's photo storage
- Returns a direct, full-resolution image URL ready to embed in posts
- Session-based requests with retry logic (up to 30 attempts)
- Python 3.7+
- A Google Cloud project with the Blogger API v3 enabled
- OAuth2 credentials (
credentials.json) from the Google Cloud Console
git clone https://github.com/Kurdeus/blogger-image.git
cd blogger-image
pip install -r requirements.txt- Go to the Google Cloud Console and create a project.
- Enable the Blogger API v3.
- Create OAuth 2.0 Client ID credentials (Desktop app type).
- Publish your project.
- Download the credentials and save them as
credentials.jsonin the project root.
from main import Blogger
uploader = Blogger("./your-image.png")
url = uploader.upload()
print(url) # Direct image URLOn first run, a browser window will open for Google OAuth2 authorization. The token is saved to
token.picklefor subsequent runs.
- Authentication — Loads or refreshes credentials from
token.pickle. If none exist, opens a browser for OAuth2 login. - Get Upload URL — Requests a resumable upload session from Google's upload endpoint.
- Upload — Sends the image binary in a single request and extracts the resulting public URL.
blogger-image/
├── main.py # Core Blogger uploader class
├── credentials.json # OAuth2 client credentials (not committed)
├── token.pickle # Saved auth token (auto-generated, not committed)
├── requirements.txt
└── README.md
- Only
credentials.jsonis needed to get started —token.pickleis generated automatically. - Add both
credentials.jsonandtoken.pickleto your.gitignoreto keep them out of version control. - The tool currently supports
image/pnguploads; modify thecontent-typeheaders inupload()for other formats.
MIT