Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rauth uses wrong request URI, causes missing consumer key error (?) #14

Closed
trtg opened this issue Jun 10, 2012 · 9 comments
Closed

rauth uses wrong request URI, causes missing consumer key error (?) #14

trtg opened this issue Jun 10, 2012 · 9 comments

Comments

@trtg
Copy link

trtg commented Jun 10, 2012

I'm trying to access the fatsecret API. I've successfully accessed this same API with the python-fatsecret library from here https://bitbucket.org/fmoo/python-fatsecret I'm using the exact same consumer key with rauth as I did with python-fatsecret but rauth is giving me the following error in get_request_token: (I added some print statements in service.py)
"response <Response [400]>
response.content Missing required parameter: oauth_consumer_key"

but I'm definitely instantiating OAuth1Service with a consumer key(and I've triple checked that it is correct).
I ran wireshark while getting a request token using rauth and python-fatsecret and noticed these differences:

rauth: OAuth Realm="http://www.fatsecret.com/" and request_URI=/oauth_request_token

python-fatsecret: OAuth Realm="" and request_URI = http://www.fatsecret.com/oauth/request_token?oauth_nonce=77769080&oauth_timestamp=1339285156&oauth_consumer_key=my_key_was_here&oauth_signature_method=HMAC-SHA1&oauth_version=1.0&oauth_signature=8a3mb2veTNIPkW6kNWr8J2pyxQ4%3D&oauth_callback=oob

Any hints on why rauth is doing a GET on the wrong URI(or am I misunderstanding what's going on)? I just pulled from the repo today, so I'm using rauth 0.4.6.

@maxcountryman
Copy link
Contributor

Hi,

It looks like consumer_secret is missing from the request. When you instantiate OAuth1Service do you provide consumer_secret?

This is a required parameter and should be provided by the provider service.

@trtg
Copy link
Author

trtg commented Jun 10, 2012

I'm instantiating OAuth1Service as follows below (i've successfully used rauth with another API before, so I don't think I'm confused about this step). Note that, yes, I did substitute the actual value of my key and secret in the actual code, I just don't want to post them here, unless necessary.

consumer_key = "my_key"
consumer_secret = "my_secret"

oauth=OAuth1Service(
name='fatsecret',
consumer_key=consumer_key,
consumer_secret=consumer_secret,
request_token_url='http://www.fatsecret.com/oauth/request_token',
access_token_url='http://www.fatsecret.com/oauth/access_token',
authorize_url='http://www.fatsecret.com/oauth/authorize',
header_auth=True)

this fails with error code 400 'Missing required parameter: oauth_consumer_key'

request_token,request_token_secret = oauth.get_request_token(method='GET')

This is what a failed rauth GET request looks like: all the parameters are in the Authorization header rather than in the URI:
http://i.imgur.com/jT2RP.png

and here's what the successful request using a different oauth library looks like:
http://i.imgur.com/MybDP.png
Notice that the URI being requested in this case contains all the necessary parameters and so does the Authorization header.
Is there just some configuration issue I'm unaware of here?

@maxcountryman
Copy link
Contributor

A couple of things: first make sure Requests is updated to >= 0.12.0. Second try setting header_auth to False. I notice that the other library you're using is sending a querystring. Usually this shouldn't happen when a provider is using header authentication. So maybe fatsecret doesn't support it? If none of that works I'll take a look at it on Monday and track down the issue.

@maxcountryman
Copy link
Contributor

Oh and one more thing: I've updated rauth to 0.4.8 which includes more transparent error handling for get_request_token. This may help us better track down exactly what's going wrong in the request.

@trtg
Copy link
Author

trtg commented Jun 10, 2012

Thanks for the help so far. Running with header_auth=False fixes the issue I mentioned above but gave me:
"Missing parameter: oauth_callback"
fatsecret expects oauth_callback='oob' for a desktop client like mine that can't accept callbacks. I see some code for handling oauth_callback and oauth_verifier in hook.py but I'm not immediately seeing how to pass that parameter into rauth. If I manually hack hook.py to assign oauth_params['oauth_callback']='oob' then my request works and returns 200. What is the proper way to specify the value of oauth_callback?

@maxcountryman
Copy link
Contributor

Parameters can be passed just as they would be to Requests. Simply pass in: params={'oauth_callback': 'oob'}.

@trtg
Copy link
Author

trtg commented Jun 10, 2012

Thanks- that addresses all my issues. Sorry for the hassle.

@trtg trtg closed this as completed Jun 10, 2012
@maxcountryman
Copy link
Contributor

Awesome! Glade it worked out. :)

@ChocoTonic
Copy link

ChocoTonic commented Sep 9, 2019

hi all,

this is a super old thread, but I was trying to get this script by @jrnold to work:
https://github.com/jrnold/fatsecretExporter/blob/master/fatsecretExport.py

and inside, it refers to this link mentioned earlier:
https://bitbucket.org/fmoo/python-fatsecret

but I get a 404
image

I'm running python 2.7 and installed oauth and ConfigureParser using pip, but when it gets to FatSecretClient, it doesn't work, and I think that has to do FatSecretClient being missing and hosting issues.

Traceback (most recent call last):
  File "C:\Users\[Redacted]\Desktop\FatSecretExporter\FatSecretExporter.py", line 9, in <module>
    from fatsecret import FatSecretClient, TokenShelf
ImportError: cannot import name FatSecretClient

Do any of you have backups of whatever was on https://bitbucket.org/fmoo/python-fatsecret or @fmoo's contact information so I could ask him about his repo?

@tristan @jobi @tko @sethdill @bbigras

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants