FitBit Auth Error still

I am getting a 500 server error in the very last step of the FitBit authentication after checking all the boxes at the FitBit website I am redirected to. After following through several threads, this seems to be a common problem that rears its head periodically. Running Home Assistant Core 0.108.5 on a Pi

I followed the steps given to create a custom component and loaded the files from the directory and changed the manifest.json as suggested:

  "domain": "fitbit",
  "name": "Fitbit",
  "documentation": "",
  "requirements": ["fitbit==0.3.1"],
  "dependencies": ["configurator", "http"],
  "codeowners": ["@robbiet480"]

And this is the error, same one everyone seems to get at some point:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/aiohttp/", line 418, in start
    resp = await task
  File "/usr/local/lib/python3.7/site-packages/aiohttp/", line 458, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/", line 119, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/", line 39, in real_ip_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/", line 72, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/", line 127, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/", line 120, in handle
    result = handler(request, **request.match_info)
  File "/config/custom_components/fitbit/", line 358, in get
    result = self.oauth.fetch_access_token(data.get("code"), redirect_uri)
  File "/usr/local/lib/python3.7/site-packages/fitbit/", line 147, in fetch_access_token
  File "/usr/local/lib/python3.7/site-packages/requests_oauthlib/", line 244, in fetch_token
    self._client.parse_request_body_response(r.text, scope=self.scope)
  File "/usr/local/lib/python3.7/site-packages/oauthlib/oauth2/rfc6749/clients/", line 411, in parse_request_body_response
    self.token = parse_token_response(body, scope=scope)
  File "/usr/local/lib/python3.7/site-packages/oauthlib/oauth2/rfc6749/", line 379, in parse_token_response
  File "/usr/local/lib/python3.7/site-packages/oauthlib/oauth2/rfc6749/", line 386, in validate_token_parameters
    raise_from_error(params.get('error'), params)
  File "/usr/local/lib/python3.7/site-packages/oauthlib/oauth2/rfc6749/", line 415, in raise_from_error
    raise cls(**kwargs)
oauthlib.oauth2.rfc6749.errors.InvalidClientError: (invalid_client)

configuration.yaml (mydomain replaced with my actual domain):

   server_port: 8123
   ssl_certificate: /ssl/fullchain.pem
   ssl_key: /ssl/privkey.pem

# Fitbit
  - platform: fitbit
    clock_format: 12H
      - "activities/steps"

@chkaloon I’m getting the same error. Did you find a way to resolve the issue?

No, I gave up for the time being. I’m hoping a future release fixes things.

I figured out a workaround! The issue is related to the Fitbit integration using OAUTH that requires https and not http. What I did was:

  • Temporarily changed my internal URL to the same https duckdns URL I use for my external URL.
  • Then, deleted my existing fitbit.conf and rebooted Home Assistant.
  • This time, when it prompted me to configure Fitbit, I saw my external URL in the instructions for setting up the Fitbit developer app. (This is key to the callback working properly)
  • Updated the credentials in the fitbit.conf with Client ID and secret.
  • Then, finally the last step to authenticate with Fitbit worked! (If you see a screen that says the client ID is incorrect, you may need to update the URL that’s trying to call to Fitbit to make sure it has the correct client ID (mine seemed to be cached to an older Fitbit app integration as I started from scratch)

You can then change your internal URL back to the HTTP HA IP (:8123). Hope this workaround helps!

Perhaps I spoke too soon. This process enables me to re-authenticate with Fitbit, but still throws the same error in the logs. And the entities don’t appear to be created. :confused:

oauthlib.oauth2.rfc6749.errors.InvalidGrantError: (invalid_grant)

Bummer. I wonder if it’s a FitBit issue or a HA integration issue.

Issue for this