Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Error : Missing parameters: state

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')

 

Best Answer
0 Votes
15 REPLIES 15

additional note :

popup browser has below URL (ref 1) and also it throws am error (ref 2)

1)

https://www.fitbit.com/oauth2/authorize?response_type=code&client_id=XXXXX&redirect_uri=http%3A%2F%2...

 

2)

Fitbit

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

Best Answer
0 Votes

Any help on above post will be highly appreciated.

Best Answer
0 Votes

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!

Best Answer
0 Votes

John

 

Please ref to the my answer inline below your question. 

 

Johncan 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)

 

Best Answer
0 Votes

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.

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google
Best Answer
0 Votes

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

Best Answer
0 Votes

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,

  • what error message you are getting?
  • What programming language and OAuth2 library are you using?
  • What is the authorization string you're using?

Thanks!

Gordon

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google
Best Answer
0 Votes

Hello @GordonFitbit 

 

  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:

https://www.fitbit.com/oauth2/authorize?response_type=code&client_id=XXXXXX&redirect_uri=http%3A%2F%...

 

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

Best Answer
0 Votes

Hi @ManasiArora 

 

Would you please private message me the complete curl script that you're executing and returns an error?

 

Thanks!

Gordon

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google
Best Answer
0 Votes

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?

Best Answer
0 Votes

Hi @fizatm,

 

Welcome to the forums! Could you please PM me your client ID so I could investigate from our end?

 

Thanks!

Best Answer
0 Votes

hi @JohnFitbit! Thank you for your response. I've sent you a PMm with my Client ID.

 

Many thanks

Best Answer
0 Votes

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 🙂

Best Answer

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,

 

Best Answer
0 Votes

This was the solution for me! Thanks

Best Answer
0 Votes