Goodreads Developers discussion

305 views
bugs > Python code in documentation not working

Comments Showing 1-9 of 9 (9 new)    post a comment »
dateUp arrow    newest »

message 1: by Anurag (last edited Aug 23, 2017 02:12PM) (new)

Anurag I am trying to fetch data using rauth in python as mentioned in documentation here

Here is my code:

from rauth.service import OAuth1Service, OAuth1Session

key ='xxxxxx'
secret = 'xxxxxxxxxxxxxxxx'
service = OAuth1Service(
consumer_key=key,
consumer_secret=secret,
name='goodreads',
request_token_url='http://www.goodreads.com/oauth/reques...',
authorize_url='http://www.goodreads.com/oauth/authorize',
access_token_url='http://www.goodreads.com/oauth/access...',
base_url='http://www.goodreads.com/'
)

request_token, request_token_secret = service.get_request_token(header_auth=True)

Instead of running smoothly its throwing this error:

KeyError: 'oauth_token'
During handling of the above exception, another exception occurred:
KeyError: "Decoder failed to handle oauth_token with data as returned by provider. A different decoder may be needed. Provider returned: b'Invalid OAuth Request'"

Whole error here: https://pastebin.com/xPdzW2aQ

I had googled all the possible reasons, but can't get any solution. I am stuck. Any help will be appreciated.


message 2: by Alper (new)

Alper Çuğun | 1 comments I'm using this: https://github.com/MattMulhern/goodreads which uses the same library and also does not work.


message 3: by Sahar (new)

Sahar Pirmoradian (spirmora) | 8 comments I got the exact same problem, so I cannot use the goodreads library to get reviews for a user.


message 4: by Lee (new)

Lee Kadin (lkadin) | 1 comments Try:

session = goodreads.get_session((access_token, access_token_secret))


message 5: by Sahar (new)

Sahar Pirmoradian (spirmora) | 8 comments The problem is that I do not have access_token or token_secret, because I haven't registered an app. I only pass client key and secret. Using the Goodreads python library, when I want to access reviews of a user I get this error. The code that raises this error is the one posted by Anurag.


message 6: by Sahar (new)

Sahar Pirmoradian (spirmora) | 8 comments I forgot to mention that I finally accessed the user reviews using the Requests and xmltodict libraries:

import requests
import xmltodict

resp = requests.get('https://www.goodreads.com/review/list...', params= {'key':Goodreads['key'], 'v': 2, 'id': myuserid})
data_dict = xmltodict.parse(resp.content)['GoodreadsResponse']
reviews_books = [r for r in data_dict['reviews']['review']]

Hope that helps.


message 7: by mayhxm (new)

mayhxm | 8 comments Hi how can i get the book reviews? Is this applicable?


message 8: by frando (last edited Mar 19, 2019 12:18PM) (new)

frando (broadishreads) | 11 comments Probably too little too late here, but it seems like goodreads has started enforcing that auth requests use https instead of http.

Using the following with the rauth library worked for me.

```
goodreads = OAuth1Service(
consumer_key=key,
consumer_secret=secret,
name='goodreads',
request_token_url='https://www.goodreads.com/oauth/reque...',
authorize_url='https://www.goodreads.com/oauth/autho...',
access_token_url='https://www.goodreads.com/oauth/acces...',
base_url='https://www.goodreads.com/'
)
```


message 9: by Shawn (new)

Shawn Falkner-Horine (dreadpirateshawn) | 2 comments It's uncanny how timely this is -- 4 days later, I ran into this, and your comment is gold. Thank you!!


back to top