Cloudflare Worker for Google Search Console
Showcase how you could build a simple cloudflare worker to download GSC data from their API using oAuth. Ideally you could set this up to send the data to BigQuery on a https://developers.cloudflare.com/workers/platform/cron-triggers/, but I will let you do that integration or save it for another day ๐ค
This codebase leverages https://github.com/kwhitley/itty-router to simplify and make it easier to read/refactor.
- index.js - main routes file
- handlers/auth.js - oauth for Google
- handlers/builder.js - UI for downloading GSC data w/access token
- handlers/homepage.js - Login to Google via oAuth
- handlers/query.js - GSC API Wrapper for downloading data
- handlers/sites.js - GSC API wrapper for showing sites you have connected in GSC
You will need to setup an API key via Google Do not forget to update the environment variables in wrangler.toml file
This repo was sparked from this Twitter Thread Special thanks to the following:
- Charly Wargnier @DataChaz
- Greg Bernhardt @GregBernhardt4
- JC Chouinard @ChouinardJC