I needed to submit 174 URLs to Google's Indexing API from a production server running Python 3.8 with system pip. The official quickstart uses google-auth , which meant either polluting system packages or spinning up a venv just to run one script.
So I did it with Node's built-in crypto instead. Zero dependencies, no install step.
What the API actually needs
Google's Indexing API takes an OAuth 2.0 access token from a service account. The flow is:
Sign a JWT with the service account's private key (RS256)
Exchange that JWT for an access token
Call the API with Authorization: Bearer <token>
Most tutorials stop at "use the library". Here's what's underneath.
Step 1: sign the JWT
import { createSign } from ' node:crypto ' ; import { readFileSync } from ' node:fs ' ;
const b64url = ( buf ) => Buffer . from ( buf ). toString ( ' base64 ' ) . replace ( / \+ /g , ' - ' ). replace ( / \/ /g , ' _ ' ). replace ( /=+$/ , '' );
const key = JSON .β¦