How I Connected Fitbit to SparkyFitness (And Fixed a Sneaky OAuth Redirect Issue)

Fitbit to SparkyFitness connection illustration

The Setup

I had SparkyFitness running in my homelab at https://address.yourdomain.com, proxyed through Nginx Proxy Manager. Everything worked fine — until I tried to connect my Fitbit account.

The Problem

I registered a Fitbit developer app, entered the Client ID and Client Secret into SparkyFitness, clicked Connect to Fitbit, and immediately hit a wall:

403 Forbidden

The authorization URL looked like this:

https://www.fitbit.com/oauth2/authorize?…&redirect_uri=http://192.168.1.101:80/fitbit/callback&…

Fitbit was trying to redirect back to my local LAN IP — http://192.168.1.101:80 — which is obviously not reachable from the outside world. The callback never made it back to my server.

The Fix

The issue was a single environment variable on my SparkyFitness server:

SPARKY_FITNESS_FRONTEND_URL=http://192.168.1.101:80

This was set to the local IP of my SparkyFitness LXC. SparkyFitness uses this variable to build all its public-facing URLs — including the OAuth redirect URI sent to Fitbit. With it pointing to a LAN address, Fitbit’s callback had nowhere to go.

I updated the .env file:

SPARKY_FITNESS_FRONTEND_URL=https://address.yourdomain.com

Then restarted the services:

systemctl restart sparkyfitness-server nginx

Clicked Connect to Fitbit again — this time the redirect URI in the authorization URL pointed to https://address.yourdomain.com/fitbit/callback. Fitbit authenticated, redirected back, and SparkyFitness successfully synced my Fitbit data.

The Lesson

If you’re self-hosting SparkyFitness (or any app with OAuth) behind a reverse proxy, and OAuth logins are failing with a 403 — check your SPARKY_FITNESS_FRONTEND_URL first. It’s likely pointing to an internal address that external services can’t reach.

All external callbacks need to go through your public domain, not your LAN IP.

TL;DR

  • Locate your SPARKY_FITNESS_FRONTEND_URL in /etc/sparkyfitness/.env
  • Change it from http://192.168.1.101:80: to https://address.yourdomain.com
  • Run systemctl restart sparkyfitness-server nginx
  • Try connecting Fitbit again

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *