Coder Social home page Coder Social logo

Comments (21)

PertuyF avatar PertuyF commented on July 29, 2024 1

Hi again,

As I successfully obtain my token using another Fitbit API client (https://github.com/magnific0/FitBit.py), it seems there is a problem with your script "gather_keys_oauth2.py".

I would say that oauthlib call using OAuth2Session should not try to validate the token during the request phase.

Best,
Fabien

from python-fitbit.

splunkzilla avatar splunkzilla commented on July 29, 2024

Same issue, but without resolution for me. I have OAuth version 1 working but I need version 2 in order to do the stuff I need. Any resolution other than the one PertuyF used?

from python-fitbit.

kevingoldsmith avatar kevingoldsmith commented on July 29, 2024

I'm having the same issue as well

from python-fitbit.

brad avatar brad commented on July 29, 2024

@kevingoldsmith @splunkzilla @PertuyF This should be fixed in #72

from python-fitbit.

splunkzilla avatar splunkzilla commented on July 29, 2024

Confirmed the fix in branch fix-oauth2. It working successfully, without any issues.

from python-fitbit.

kevingoldsmith avatar kevingoldsmith commented on July 29, 2024

Also tried the branch and it works for me too.

from python-fitbit.

chw333 avatar chw333 commented on July 29, 2024

Also tried the branch and it works for me too.

from python-fitbit.

PertuyF avatar PertuyF commented on July 29, 2024

Look like it's been merged on master, it worked for me.

from python-fitbit.

bspeice avatar bspeice commented on July 29, 2024

Can this fix please be released? The version available through pypi doesn't currently support OAuth2 as far as I can tell.

from python-fitbit.

randi120 avatar randi120 commented on July 29, 2024

I don't think this is fully working yet.
I just ran into some trouble using the latest version (master hash 01c2023) which has the fixed as mentioned by @brad #70

Specifically:
oauthlib.oauth2.rfc6749.errors.MissingTokenError: (missing_token) Missing access token parameter.

I revert to the version before the fix (master hash f0166f6)
and things work correctly. I am able to get access tokens without issues (no other changes made)

I quickly glanced at the commit diffs between the two version and this is the only change I could potentially see as being related.

from python-fitbit.

Josh2K avatar Josh2K commented on July 29, 2024

This also my first attempt at OAuth2. I'm not having any luck authenticating either. I put in http:/127.0.0.1:8080 as my Callback URL (is that right?) in the App registration page. When I use the "OAuth 2.0 Client ID" and "Client (Consumer) Secret" values provided as command line parameters in gather_keys_oauth2.py, it seems to launch a webserver and causes my browser to go to a fitbit site but the webpage just says:

"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"

I'm using the latest master branch. Anyone have any suggestions?

Thanks,

from python-fitbit.

JamesGardiner avatar JamesGardiner commented on July 29, 2024

@randi120 I'm using 01c2023 without issue.

from python-fitbit.

JamesGardiner avatar JamesGardiner commented on July 29, 2024

@Josh2K your callback URL should be http://127.0.0.1:8080/, not http:/127.0.0.1:8080

from python-fitbit.

randi120 avatar randi120 commented on July 29, 2024

@JamesGardiner are you getting new tokens or using already saved ones?

When I try to get tokens on 01c2023 I get the following:

Traceback (most recent call last):
  File "./my_oauth2_gather_key.py", line 78, in <module>
    getter.set_code(callback_answer.code)
  File "./my_oauth2_gather_key.py", line 41, in set_code
    self.oauth.fetch_access_token(code, self.redirect_url)
  File "~/fitbit/python-fitbit/fitbit/api.py", line 274, in fetch_access_token
    code=code)
  File "/usr/local/lib/python2.7/dist-packages/requests_oauthlib/oauth2_session.py", line 199, in fetch_token
    self._client.parse_request_body_response(r.text, scope=self.scope)
  File "/usr/local/lib/python2.7/dist-packages/oauthlib/oauth2/rfc6749/clients/base.py", line 409, in parse_request_body_response
    self.token = parse_token_response(body, scope=scope)
  File "/usr/local/lib/python2.7/dist-packages/oauthlib/oauth2/rfc6749/parameters.py", line 376, in parse_token_response
    validate_token_parameters(params)
  File "/usr/local/lib/python2.7/dist-packages/oauthlib/oauth2/rfc6749/parameters.py", line 386, in validate_token_parameters
    raise MissingTokenError(description="Missing access token parameter.")
oauthlib.oauth2.rfc6749.errors.MissingTokenError: (missing_token) Missing access token parameter.

getter is an object that handles the generation of access token url and the passing back of the code to get new access and refresh tokens.

It errors at the point when trading in the fitbit code for tokens. In other words,
access token url is okay, the user has provided permission, fitbit issue the callback with the necessary code.

The same exact code works on f0166f6.
I am not sure how to explain it...

from python-fitbit.

JamesGardiner avatar JamesGardiner commented on July 29, 2024

@randi120 I've tested both, first using an existing app and by registering a new dummy app. Both worked for me. Apologies for not being able to offer more insight to your problem.

from python-fitbit.

randi120 avatar randi120 commented on July 29, 2024

@JamesGardiner yeah. is a weird issue...
thanks.

from python-fitbit.

bspeice avatar bspeice commented on July 29, 2024

I've had issues in the past where I would get authorization issues if I didn't set the "redirect URL" in Fitbit to match up with what the OAuth API was using. Make sure that if you specify "localhost" as the redirect URI that you have "localhost" as the redirect URI in your fitbit application settings.

from python-fitbit.

percyperez avatar percyperez commented on July 29, 2024

@randi120 I was having the same error as well but not anymore. Have you tried to install requirements in a new virtual environment? After you do that, test the package again. Also, what is the installed version of requests-oauthlib? Is it 0.6.1?

from python-fitbit.

percyperez avatar percyperez commented on July 29, 2024

@PertuyF If you don't have this issue anymore, can we close the issue?

from python-fitbit.

randi120 avatar randi120 commented on July 29, 2024

@percyperez, Thank you!
upgrading requests-oauthlib to 0.6.1 fixed the issue for me.

from python-fitbit.

ashutosh-aneja avatar ashutosh-aneja commented on July 29, 2024

oauthlib.oauth2.rfc6749.errors.MissingTokenError
oauthlib.oauth2.rfc6749.errors.MissingTokenError: (missing_token) Missing access token parameter.

if 'code' not in request.args and 'state' not in request.args:
return redirect(url_for('login'))
else:
google = get_google_auth(state=session['oauth_state'])
try:
token = google.fetch_token(Auth.TOKEN_URI,client_secret=Auth.CLIENT_SECRET,authorization_response=request.url)
except HTTPError:
return 'HTTPError occurred.'
google = get_google_auth(token=token)
resp = google.get(Auth.USER_INFO)
Open an interactive python shell in this frame if resp.status_code == 200:

plz help me ,how to solve this

from python-fitbit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.