A simple Go proxy server that authenticates requests to the IGDB API (v4). It handles OAuth2 token generation/refreshing with Twitch and hides your Twitch Client credentials from the client.
- Proxies requests to
https://api.igdb.com/v4. - Validates a client-side API Key (
X-Proxy-Key). - Automatically handles Twitch OAuth2 Client Credentials flow.
- Refreshes the access token 1 minute before expiration.
- Injects
Client-IDandAuthorizationheaders into proxied requests.
-
Build the server:
go build -o igdb-proxy
-
Run the server: You must provide the following environment variables:
export PORT=8080 # Optional, defaults to 8080 export PROXY_API_KEYS="key1,key2" # Comma-separated list of keys export TWITCH_CLIENT_ID="abc..." # Your Twitch Client ID export TWITCH_CLIENT_SECRET="xyz..." # Your Twitch Client Secret ./igdb-proxy
Make requests to the proxy just like you would to IGDB, but include your configured X-Proxy-Key header.
Example:
To fetch games from IGDB:
curl -X POST http://localhost:8080/games \
-H "X-Proxy-Key: my-secret" \
-H "Content-Type: text/plain" \
-d "fields name, rating; limit 10;"The proxy will forward this to https://api.igdb.com/v4/games with the correct authentication headers.