Tesla Fleet API OAuth (Authorization Code + Refresh Rotation)

The practical OAuth setup that actually works in production: exact redirect URIs, token exchange, refresh rotation, concurrency locks, and the fastest way to debug 401/403 errors.

← Back to the Tesla Fleet API guide hub • Next: Public key / PEM hosting • Also: Telemetry vs polling

Want the working checklist + updates? Get the PDF.

I’ll email you the Fleet API owner checklist (OAuth + PEM hosting + telemetry cost rules).

  • OAuth: redirect URI + refresh-token rotation checklist
  • Common errors: 401/403 triage steps
  • Cost-safe design: when to use Telemetry vs polling
Download PDF Get EVFleetPulse beta
No spam. Unsubscribe anytime.

1) Which OAuth flow to use

For most owner projects, use Authorization Code flow. You do the one-time consent in a browser and then your backend refreshes access tokens using the refresh token.

Rule: Do not put client secrets in a browser app. Exchange tokens server-side.

2) Redirect URI rules (the #1 failure)

3) Refresh token rotation (the #2 failure)

When you refresh, Tesla returns a new refresh token. Store it and use it next time. If you keep using an old refresh token, you’ll eventually start seeing 401/403.

Concurrency: Use a per-user single-flight lock so two refreshes don’t invalidate each other.

4) Fast 401/403 checklist

Minimal snippets

Token exchange (authorization_code)

curl -sS -X POST \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "grant_type=authorization_code" \
  -d "client_id=YOUR_CLIENT_ID" \
  -d "client_secret=YOUR_CLIENT_SECRET" \
  -d "code=AUTH_CODE_FROM_REDIRECT" \
  -d "redirect_uri=https://yourdomain.com/callback" \
  "https://auth.tesla.com/oauth2/v3/token"

Refresh (rotate refresh token)

curl -sS -X POST \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "grant_type=refresh_token" \
  -d "client_id=YOUR_CLIENT_ID" \
  -d "client_secret=YOUR_CLIENT_SECRET" \
  -d "refresh_token=YOUR_CURRENT_REFRESH_TOKEN" \
  "https://auth.tesla.com/oauth2/v3/token"