Coder Social home page Coder Social logo

libgreader's Introduction

libgreader readme

libgreader is a Python library for authenticating and interacting with the unofficial Google Reader API. It currently supports all major user authentication methods (ClientLogin, OAuth2) and aims to simplify the many features that Google Reader offers. RSS ain't dead yet (but Google Reader may be)!

Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php

Current Status

As of March 2013, Google plans to shutdown down Google Reader on July 1st, 2013, which kind of makes this library not so useful.

There are plans to recreate the Google Reader API in several open source projects, so perhaps this library could be extended to support multiple APIs. At present, the author is waiting to see how things turn out and what course of action would make the most sense.

Features

  • Support for all Google recommended authentication methods, for easy integration with existing web or desktop applications
  • Explanation of most of the Google Reader API endpoints, which Google has never really opened up
  • Convenient functions and models for working with those endpoints
  • A modest integration test suite!

Usage

It's as simple as:

>>> from libgreader import GoogleReader, ClientAuthMethod, Feed
>>> auth = ClientAuthMethod('YOUR USERNAME','YOUR PASSWORD')
>>> reader = GoogleReader(auth)
>>> print reader.getUserInfo()
{u'userName': u'Foo', u'userEmail': u'[email protected]', u'userId': u'16058940398976999581', u'userProfileId': u'100275409503040726101', u'isBloggerUser': False, u'signupTimeSec': 0, u'isMultiLoginEnabled': False}`

For more examples with all of the authentication methods, see the USAGE file.

Installation

libgreader is on pypi at http://pypi.python.org/pypi/libgreader/

$ pip install libgreader

or

$ easy_install libgreader

Testing and Contribution

Want to test it out or contribute some changes?

First, fork the repository on Github to make changes on your private branch. Then, create a dev environment using a virtualenv:

$ pip install virtualenvwrapper
$ mkvirtualenv venv-libgreader --no-site-packages

Checkout your fork and then run the tests:

$ python setup.py test

Now hack away! Write tests which show that a bug was fixed or that the feature works as expected. Then send a pull request and bug me until it gets merged in and published.

Thanks

Originally created with help from:

http://blog.martindoms.com/2009/08/15/using-the-google-reader-api-part-1/

http://code.google.com/p/pyrfeed/wiki/GoogleReaderAPI

http://groups.google.com/group/fougrapi

Since then, many have contributed to the development of libgreader.

libgreader's People

Contributors

aaronkurtz avatar askedrelic avatar kudo avatar stephenmcd avatar twidi avatar valentinalexeev avatar wuyuntao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

libgreader's Issues

markAllRead HTTP error

I get the followoing error when trying to mark items as read (same thing happens when you try and star an item):

In [57]: ars.markAllRead()
---------------------------------------------------------------------------
HTTPError                                 Traceback (most recent call last)
<ipython-input-57-0ebb71872288> in <module>()
----> 1 ars.markAllRead()

/Users/Steve/Virtual/crazytown/lib/python2.6/site-packages/libgreader/items.pyc in markAllRead(self)
    198         for category in self.categories:
    199             category.countUnread()
--> 200         return super(BaseFeed, self).markAllRead()
    201 
    202     def toArray(self):

/Users/Steve/Virtual/crazytown/lib/python2.6/site-packages/libgreader/items.pyc in markAllRead(self)
     88             item.read = True
     89             item.canUnread = False
---> 90         result = self.googleReader.markFeedAsRead(self)
     91         return result.upper() == 'OK'
     92 

/Users/Steve/Virtual/crazytown/lib/python2.6/site-packages/libgreader/googlereader.pyc in markFeedAsRead(self, feed)
    185         return self.httpPost(
    186             ReaderUrl.MARK_ALL_READ_URL,
--> 187             {'s': feed.id, })
    188 
    189     def subscribe(self, feedUrl):

/Users/Steve/Virtual/crazytown/lib/python2.6/site-packages/libgreader/googlereader.pyc in httpPost(self, url, post_parameters)
    222         Wrapper around AuthenticationMethod post()
    223         """
--> 224         return self.auth.post(url, post_parameters)
    225 
    226     def _addFeed(self, feed):

/Users/Steve/Virtual/crazytown/lib/python2.6/site-packages/libgreader/auth.pyc in post(self, url, postParameters, urlParameters)
     94         req.add_header('Authorization','GoogleLogin auth=%s' % self.auth_token)
     95         postString = self.postParameters(postParameters)
---> 96         r = urllib2.urlopen(req, data=postString)
     97         data = r.read()
     98         r.close()

/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib2.py in urlopen(url, data, timeout)
    124     if _opener is None:
    125         _opener = build_opener()
--> 126     return _opener.open(url, data, timeout)
    127 
    128 def install_opener(opener):

/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib2.py in open(self, fullurl, data, timeout)
    395         for processor in self.process_response.get(protocol, []):
    396             meth = getattr(processor, meth_name)
--> 397             response = meth(req, response)
    398 
    399         return response

/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib2.py in http_response(self, request, response)
    508         if not (200 <= code < 300):
    509             response = self.parent.error(
--> 510                 'http', request, response, code, msg, hdrs)
    511 
    512         return response

/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib2.py in error(self, proto, *args)
    433         if http_err:
    434             args = (dict, 'default', 'http_error_default') + orig_args
--> 435             return self._call_chain(*args)
    436 
    437 # XXX probably also want an abstract factory that knows when it makes

/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib2.py in _call_chain(self, chain, kind, meth_name, *args)
    367             func = getattr(handler, meth_name)
    368 
--> 369             result = func(*args)
    370             if result is not None:
    371                 return result

/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib2.py in http_error_default(self, req, fp, code, msg, hdrs)
    516 class HTTPDefaultErrorHandler(BaseHandler):
    517     def http_error_default(self, req, fp, code, msg, hdrs):
--> 518         raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
    519 
    520 class HTTPRedirectHandler(BaseHandler):

HTTPError: HTTP Error 400: Bad Request

raise IOError("Error setting Access Token")

OAuth callback response is 400. I don't know why? after granting access and getting redirected to "myapp.com:8080", I get the IOError.

I am coding in django and here is my code:

def home(request):
    info = []
    from libgreader import GoogleReader, OAuthMethod, Feed
    if request.method == 'GET' and request.GET.get("oauth_verifier"):
        auth = OAuthMethod(settings.GOOGLE_OAUTH2_CLIENT_ID, settings.GOOGLE_OAUTH2_CLIENT_SECRET)
        #auth = request.session['auth'] 
        auth.setAccessTokenFromCallback(request.GET["oauth_token"], request.session["token_secret"], request.GET["oauth_verifier"])
        reader = GoogleReader(auth)
        print reader.getUserInfo()
        print request.session['token']
        print request.session['token_secret']
        auth_url = None
        info = reader       
    else:
        auth = OAuthMethod(settings.GOOGLE_OAUTH2_CLIENT_ID, settings.GOOGLE_OAUTH2_CLIENT_SECRET)
        auth.setCallback("http://myapp.com:8080/")
        token, token_secret = auth.setAndGetRequestToken()
        request.session['token']= token
        request.session['token_secret']= token_secret
        request.session['auth'] = auth
        auth_url = auth.buildAuthUrl()
        return render(request, 'home.html', {'now':datetime.datetime.now(), 'auth_url': auth_url, 'info': info})

Oath2 test

I cannot make use of Oath2, I don't know why. test shows also...

ERROR: test_full_auth_and_access_userdata (__main__.TestOAuth2)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test_auth.py", line 150, in test_full_auth_and_access_userdata
    auth.setAccessToken()
  File "build/bdist.linux-x86_64/egg/libgreader/auth.py", line 297, in setAccessToken
    raise IOError('Error getting Access Token')
IOError: Error getting Access Token

Running test against other endpoint?

We (@superfeedr) are trying to produce a compatible Google Reader API, so that it's easy for anyone to change their endpoint and still get their libraries to work.
To achieve that I wanted to know what needed to be changed to run the test suite against our endpoint.

Thanks!

Python 3 Compatibility

Python3 support has been requested.

  • With the test suites and tox support, both Py2/Py3 support can be tested.
  • I've been wanting to move all the backend HTTP library calls to Requests, which is also Py3 compatible and that would remove any problems with the http lib/url requests library
  • Everything else in the libgreader is standard python code, so I think that writing 2 and 3 compatible code is possible, versus using six or something.

Google API for Python: action token flow is missing

In order to perform edit operations a separate token is required. When using GAP decorator it is not requested and not added to POST operations. As such all edit operations fail with invalid key response.

How many times do I need to set? (avoid the google ban)

I have try this awesome library.
But when I try many times, the google server don't response me the request.

Did everybody know , what best interval , that will not only effective to crawl the feeds from google reader, but also avoid the google robot ban?

bugs exist in OAuth2Method?

auth.py has compile error, I change it to :
... def post(self, url, postParameters=None, urlParameters={}): ... getString = self.getParameters(urlParameters) request = urllib2.Request(url + '?' + getString) '#' below is original one '#' request = urllib2.Request(url + '?' + self.getParameters(parameters)) postString = self.postParameters(postParameters) ...
It's a pitty, this still can not work...
Can you help me out this problem?

Fail to subscribe

A basic test for subscribing to a new feed fails with the latest git:

#!/usr/bin/python2

from libgreader import GoogleReader, ClientAuthMethod, Feed

auth = ClientAuthMethod('[email protected]', 'password')

reader = GoogleReader(auth)

# Works
print '%s' % reader.getUserInfo()

# Doesn't Work
print '%s' % reader.subscribe("http://xkcd.com/atom.xml")

I actually found libgreader after my own homebrew experiment had the same 400 response, so perhaps the API has changed?

Anyway I get the following after the user info is printed:

Traceback (most recent call last):
  File "./test.py", line 11, in <module>
    print '%s' % reader.subscribe("http://xkcd.com/atom.xml")
  File "/home/jack/src/libgreader/libgreader/googlereader.py", line 200, in subscribe
    {'ac':'subscribe', 's': feedUrl})
  File "/home/jack/src/libgreader/libgreader/googlereader.py", line 252, in httpPost
    return self.auth.post(url, post_parameters)
  File "/home/jack/src/libgreader/libgreader/auth.py", line 96, in post
    r = urllib2.urlopen(req, data=postString)
  File "/usr/lib/python2.7/urllib2.py", line 126, in urlopen
    return _opener.open(url, data, timeout)
  File "/usr/lib/python2.7/urllib2.py", line 406, in open
    response = meth(req, response)
  File "/usr/lib/python2.7/urllib2.py", line 519, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python2.7/urllib2.py", line 444, in error
    return self._call_chain(*args)
  File "/usr/lib/python2.7/urllib2.py", line 378, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.7/urllib2.py", line 527, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 400: Bad Request

Proxy support

There is no option at the moment to pass proxy parameters to libgreader or oauth2 backend.

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.