home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
74.19k stars 31.15k forks source link

Issues setting up Fitbit #2026

Closed justyns closed 8 years ago

justyns commented 8 years ago

Home Assistant release (hass --version): 0.19.2

Python release (python3 --version): Python 3.4.1

Component/platform: sensor/Fitbit

Description of problem: Attempting to set up the fitbit sensor, and ran into a few issues.

  1. After configuring fitbit.conf, hass-ui prompted to go to http://192.168.1.44:8123/auth/fitbit (side note: this should probably use whatever the hostname/url is the user is using instead.) The real issue though is that I kept getting API password missing or incorrect errors when going to that URL. I made sure I was logged in using that same url, and could access the rest of the app. Adding ?api_password=mypassword fixed that error.
  2. I was redirected to: https://www.fitbit.com/oauth2/authorize?response_type=code&client_id=None&redirect_uri=http%3A%2F%2F192.168.1.44%3A8123%2Fauth%2Ffitbit%2Fcallback&scope=activity+heartrate+nutrition+profile+settings+sleep+weight&state=snip and received:
The app you're trying to connect did not provide valid information to Fitbit. Please report this issue to them.

Developer information: unauthorized_client - Invalid client_id

I restarted home-assistant, and None was still being sent as the client_id.

Expected:

Problem-relevant configuration.yaml entries and steps to reproduce:

# Fitbit
- platform: fitbit
  monitored_resources:
    - "activities/steps"
    - "activities/tracker/steps"
    - "sleep/minutesAsleep"

fitbit.conf

{"client_secret": "xxx", "client_id": "000XXX"}

Additional info:

balloob commented 8 years ago

CC @robbiet480

turbokongen commented 8 years ago

I am having the exact same proplem at my setup.

  1. mai 2016 08:42 skrev "Paulus Schoutsen" notifications@github.com:

CC @robbiet480 https://github.com/robbiet480

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/home-assistant/home-assistant/issues/2026#issuecomment-218071782

carlosmgr commented 8 years ago

That is a bug. "client_id=None"

you just have to change from None to your id.

I had the same problem, but what i have found is that i do not receave any data from fitbit.

Apart from this, @robbiet480, please add the alarm and battery

turbokongen commented 8 years ago

Yes, tried that too. Then I get: Developer information: invalid_request - Invalid redirect_uri parameter value

turbokongen commented 8 years ago

Huh... Suddenly I got one step further. I could click the allow button, but then: Something went wrong when attempting authenticating with Fitbit. The error encountered was (missing_token) Missing access token parameter.. Please try again! And fitbit.conf gets like this: {"refresh_token": null, "client_secret": null, "client_id": null, "access_token": null} Even though I filled it with client_id and client_secret

carlosmgr commented 8 years ago

you can add this to your fitbit config and your client id and access token will not be changed.

- platform: fitbit
  client_id: xxxxx
  client_secret: xxxx
  monitored_resources:
    - "activities/steps"

Also at dev.fitbit.com you need to add "/auth/fitbit/callback"

robbiet480 commented 8 years ago

Please upgrade to Home Assistant version 0.19.3 which was just released.

Marauder0408 commented 8 years ago

Still not working for me. I've got my cliend ID and secret in the config file and the fitbit.conf. What are the correct settings for the app on dev.fitbit? I'm thinking that must be my problem.

Application name - Home Assistant Description - Home Assistant personal use Application website - http://localhost:8123/auth/fitbit Organization - hass Organization website - http://localhost:8123/auth/fitbit OAuth 2.0 Application Type - Personal Callback URL - http://192.168.0.103:8123/auth/fitbit/ Default Access type - Read only

robbiet480 commented 8 years ago

@Marauder0408 Those settings all look correct (the only ones that really matter there are the application type and callback URL). What error are you getting?

Also, please remove fitbit.conf if it exists and shut down Home Assistant. Then start it back up and try authenticating again.

Marauder0408 commented 8 years ago

@robbiet480 Developer information: unauthorized_client - Invalid client_id

robbiet480 commented 8 years ago

@Marauder0408 FYI I just noticed your callback URL is incorrect, it should be http://192.168.0.103:8123/auth/fitbit/callback.

Try using this URL instead to start the auth flow

Marauder0408 commented 8 years ago

Made the change and the url given by the configurator still didn't work but that URL you just said to try worked!

Thanks!

robbiet480 commented 8 years ago

@Marauder0408 There's a caching issue somewhere in HA. The URL I gave you had a cachebuster on the end of it.

For anyone else reading this, if you tried starting Fitbit auth previously and had issues, please now try again but add ?cache=345845845 to the end of your /auth/fitbit URL (the one that you use to start the auth flow).

justyns commented 8 years ago

Thanks @robbiet480. I was able to get this working with 0.19.3, but I still had the issue of having to add ?api_password=<password> to the /auth/fitbit url and also to the callback url fitbit sent back to me.