07-21-2019 09:14
07-21-2019 09:14
Hi
I am trying to make a simple call to my firbit surge to pull my activity data but unfortunately I am getting the following error when the API call is trying the fetch the token through call back URL ( http://127.0.0.1:8080/)
Note: I followed the right steps to register my application to fetch the Client_ID and client_Secret values.
404 Not Found
Missing parameters: state
Traceback (most recent call last): File "C:\ProgramData\Anaconda3\lib\site-packages\cherrypy\_cpdispatch.py", line 54, in __call__ return self.callable(*self.args, **self.kwargs) TypeError: index() missing 1 required positional argument: 'state' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\ProgramData\Anaconda3\lib\site-packages\cherrypy\_cprequest.py", line 628, in respond self._do_respond(path_info) File "C:\ProgramData\Anaconda3\lib\site-packages\cherrypy\_cprequest.py", line 687, in _do_respond response.body = self.handler() File "C:\ProgramData\Anaconda3\lib\site-packages\cherrypy\lib\encoding.py", line 219, in __call__ self.body = self.oldhandler(*args, **kwargs) File "C:\ProgramData\Anaconda3\lib\site-packages\cherrypy\_cpdispatch.py", line 60, in __call__ raise sys.exc_info()[1] File "C:\ProgramData\Anaconda3\lib\site-packages\cherrypy\_cpdispatch.py", line 58, in __call__ test_callable_spec(self.callable, self.args, self.kwargs) File "C:\ProgramData\Anaconda3\lib\site-packages\cherrypy\_cpdispatch.py", line 157, in test_callable_spec raise cherrypy.HTTPError(404, message=message) cherrypy._cperror.HTTPError: (404, 'Missing parameters: state')
07-21-2019 10:06
07-21-2019 10:06
additional note :
popup browser has below URL (ref 1) and also it throws am error (ref 2)
1)
2)
The app you're trying to connect did not provide valid information to Fitbit. Please report this issue to them.
Developer information: invalid_request - Invalid redirect_uri parameter value
07-23-2019 22:28
07-23-2019 22:28
Any help on above post will be highly appreciated.
07-24-2019 16:23
07-24-2019 16:23
Hi @rajeev2301,
I'll be happy look into this for you. So that I can see what's going on, can you clarify when you are seeing the 404 missing parameter: state error?
Also, when are you seeing the invalid_request - Invalid redirect_uri parameter value error? Is this right after selecting which scopes to consent to during the authorization process?
One of the causes for this error is if the callback URI that you have in place at your application settings in dev.fitbit.com/apps is not entered the same in your application. Both your callback URI in the application and dev.fitbit.com/apps settings must match.
Looking forward to hearing from you!
07-28-2019 11:05
07-28-2019 11:05
John
Please ref to the my answer inline below your question.
John : can you clarify when you are seeing the 404 missing parameter: state error?
Rajeev : I am seeing 404 error when I am trying to run the python code ( successfully executed - No syntax error) it pops up a a browser ( I believe to authorize - https://www.fitbit.com/oauth2/authorize?client_id=22DNDX.......)
here is the browser output message
404 Not Found Missing parameters: state Traceback (most recent call last): File "C:\ProgramData\Anaconda3\lib\site-packages\cherrypy\_cpdispatch.py", line 54, in __call__ return self.callable(*self.args, **self.kwargs) TypeError: index() missing 1 required positional argument: 'state' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\ProgramData\Anaconda3\lib\site-packages\cherrypy\_cprequest.py", line 628, in respond self._do_respond(path_info) File "C:\ProgramData\Anaconda3\lib\site-packages\cherrypy\_cprequest.py", line 687, in _do_respond response.body = self.handler() File "C:\ProgramData\Anaconda3\lib\site-packages\cherrypy\lib\encoding.py", line 219, in __call__ self.body = self.oldhandler(*args, **kwargs) File "C:\ProgramData\Anaconda3\lib\site-packages\cherrypy\_cpdispatch.py", line 60, in __call__ raise sys.exc_info()[1] File "C:\ProgramData\Anaconda3\lib\site-packages\cherrypy\_cpdispatch.py", line 58, in __call__ test_callable_spec(self.callable, self.args, self.kwargs) File "C:\ProgramData\Anaconda3\lib\site-packages\cherrypy\_cpdispatch.py", line 157, in test_callable_spec raise cherrypy.HTTPError(404, message=message) cherrypy._cperror.HTTPError: (404, 'Missing parameters: state')
John : Also, when are you seeing the invalid_request - Invalid redirect_uri parameter value error? Is this right after selecting which scopes to consent to during the authorization process?
Rajeev : Yes, looks like it's right after ot during the authorization process.
John : One of the causes for this error is if the callback URI that you have in place at your application settings in dev.fitbit.com/apps is not entered the same in your application.
Rajeev : I am not sure where I am missing call back URI in my code. BTW my Callback URL is http://127.0.0.1:8080. I am sure my call back is correct since as soon as I run my Python code it get the below message.
[28/Jul/2019:10:35:26] ENGINE Listening for SIGTERM. [28/Jul/2019:10:35:26] ENGINE Bus STARTING CherryPy Checker: The Application mounted at '' has an empty config. [28/Jul/2019:10:35:26] ENGINE Set handler for console events. [28/Jul/2019:10:35:26] ENGINE Started monitor thread 'Autoreloader'. [28/Jul/2019:10:35:26] ENGINE Serving on http://127.0.0.1:8080 [28/Jul/2019:10:35:26] ENGINE Bus STARTED
please ref below my code snippets.
import fitbit import gather_keys_oauth2 as Oauth2 import pandas as pd import datetime CLIENT_ID = 'XXXXXX' CLIENT_SECRET = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' server = Oauth2.OAuth2Server(CLIENT_ID, CLIENT_SECRET) server.browser_authorize() ACCESS_TOKEN = str(server.fitbit.client.session.token['access_token']) REFRESH_TOKEN = str(server.fitbit.client.session.token['refresh_token']) auth2_client = fitbit.Fitbit(CLIENT_ID, CLIENT_SECRET, oauth2=True, access_token=ACCESS_TOKEN, refresh_token=REFRESH_TOKEN) yesterday = str((datetime.datetime.now() - datetime.timedelta(days=1)).strftime("%Y%m%d")) yesterday2 = str((datetime.datetime.now() - datetime.timedelta(days=1)).strftime("%Y-%m-%d")) today = str(datetime.datetime.now().strftime("%Y%m%d")) fit_statsHR = auth2_client.intraday_time_series('activities/heart', base_date=yesterday2, detail_level='1sec') time_list = [] val_list = [] for i in fit_statsHR['activities-heart-intraday']['dataset']: val_list.append(i['value']) time_list.append(i['time']) heartdf = pd.DataFrame({'Heart Rate':val_list,'Time':time_list}) heartdf.to_csv('C:/Users/Ratna/Downloads/python-fitbit-master/Heart'+ \ yesterday+'.csv', \ columns=['Time','Heart Rate'], header=True, \ index = False)
08-22-2019 16:36
08-22-2019 16:36
Hi @rajeev2301
Are you still having a problem authorizing the connection?
One thing I noticed about your callback URL is the URL should be HTTPS, not HTTP. Also, the state parameter is optional. I'm assuming either your OAuth2 library is requiring it, or you have it referenced somewhere in your code and there is no value assigned to it.
03-15-2020 23:52
03-15-2020 23:52
Did we ever reach a conclusion about this issue? I have the same problem and cannot seem to find a solution anywhere else about it
03-16-2020 23:38
03-16-2020 23:38
Hi @john0315
We can try to help resolve any problem that you're having with the APIs. Would you please provide a little more information about your problem? For example,
Thanks!
Gordon
05-28-2020 03:42
05-28-2020 03:42
Hello @Gordon-C
I'm absolutely new to fitbit app development. have been following the tutorial at https://towardsdatascience.com/collect-your-own-fitbit-data-with-python-ff145fa10873
my Authorization URL is:
After i select all and click on allow it redirects me to
http://127.0.0.1:8080/?code=e0f60d9bef7cefacdaddbc01f7254dd6787c6729
when i paste the code in
OAuth 2.0 tutorial page
i get a curl script when i execute it, i get the following error {"errors":[{"errorType":"invalid_client","message":"Invalid authorization header format. The header was not recognized to be a valid header for any of known implementations or a client_id w
as not specified in case of a public client Received header = null. Visit https://dev.fitbit.com/docs/oauth2 for more information on the Fitbit Web API authorization process."}],"success":f
alse}
What am i doing wrong?
i Dont own a fit bit myself, i need to develop an app that is like a dashboard for a whole lot of fitbit users
Thanks in Advance
Manasi
05-28-2020 14:41
05-28-2020 14:41
Hi @ManasiArora
Would you please private message me the complete curl script that you're executing and returns an error?
Thanks!
Gordon
10-05-2020 22:58
10-05-2020 22:58
I've been trying to change the URL to https in the relevant code/app settings but it remains http once I execute the code:
[06/Oct/2020:16:43:34] ENGINE Bus STARTING CherryPy Checker: The Application mounted at '' has an empty config. [06/Oct/2020:16:43:34] ENGINE Started monitor thread 'Autoreloader'. [06/Oct/2020:16:43:35] ENGINE Serving on http://127.0.0.1:8080 [06/Oct/2020:16:43:35] ENGINE Bus STARTED
Tutorial: https://www.kdnuggets.com/2020/02/using-fitbit-web-api-python.html
I get a blank screen on the Authorisation page with the following error flashing for 1 second before disappearing too:
The app you're trying to connect did not provide valid information to Fitbit. Please report this issue to them.
Developer information: invalid_request - Invalid redirect_uri parameter value
I've checked and made sure that the callback URL is the same in the code and the app settings. Any suggestions on how to tackle this?
10-12-2020 15:12
10-12-2020 15:12
Hi @fizatm,
Welcome to the forums! Could you please PM me your client ID so I could investigate from our end?
Thanks!
10-21-2020 19:58
12-12-2020 13:12
12-12-2020 13:12
Idk who needs to see this, but this turned out to be my problem.
Your redirect uri needs to be character-perfect, including the ' / ' at the end.
Hopefully that helps someone else, too. Happy coding 🙂
02-22-2021 05:28
02-22-2021 05:28
Hi I am new trying the API,
@JohnFitbit I have the same issue ¿Could you help me with that?
Traceback (most recent call last):
File "D:\Users\Rodo\AppData\Local\Programs\Python\Python39\lib\site-packages\cherrypy\_cpdispatch.py", line 54, in __call__
return self.callable(*self.args, **self.kwargs)
TypeError: index() missing 1 required positional argument: 'state'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\Users\Rodo\AppData\Local\Programs\Python\Python39\lib\site-packages\cherrypy\_cprequest.py", line 638, in respond
self._do_respond(path_info)
File "D:\Users\Rodo\AppData\Local\Programs\Python\Python39\lib\site-packages\cherrypy\_cprequest.py", line 697, in _do_respond
response.body = self.handler()
File "D:\Users\Rodo\AppData\Local\Programs\Python\Python39\lib\site-packages\cherrypy\lib\encoding.py", line 219, in __call__
self.body = self.oldhandler(*args, **kwargs)
File "D:\Users\Rodo\AppData\Local\Programs\Python\Python39\lib\site-packages\cherrypy\_cpdispatch.py", line 60, in __call__
raise sys.exc_info()[1]
File "D:\Users\Rodo\AppData\Local\Programs\Python\Python39\lib\site-packages\cherrypy\_cpdispatch.py", line 58, in __call__
test_callable_spec(self.callable, self.args, self.kwargs)
File "D:\Users\Rodo\AppData\Local\Programs\Python\Python39\lib\site-packages\cherrypy\_cpdispatch.py", line 157, in test_callable_spec
raise cherrypy.HTTPError(404, message=message)
cherrypy._cperror.HTTPError: (404, 'Missing parameters: state')
Best Regards,
03-28-2023 04:55
03-28-2023 04:55
This was the solution for me! Thanks