Calling Blogger API using OAuth 2.0

1 view
Skip to first unread message

user1260969 via StackOverflow

unread,
Oct 22, 2016, 10:34:06 AM10/22/16
to google-appengin...@googlegroups.com

i am working on a simple web application using python in google appengine. which will display list of blogs in my google account.

When i launch the page, it opened "Request for permission" Page from google. After clicking allow button, it redirected me to same page asking for permission again.

Can you help me on this ?

i could see secret token in my appengine data store, is it possible to use this to perform blogger API calls ( like posting new post) ?

Here is the my code

from google.appengine.ext import webapp
from google.appengine.ext.webapp import util
from oauth2client.contrib.appengine import OAuth2Decorator
from apiclient.discovery import build
import pprint

decorator = OAuth2Decorator(
  client_id='client-id-here',
  client_secret='client_secret-here',
  scope='https://www.googleapis.com/auth/blogger')

service = build('blogger', 'v3')

class MainHandler(webapp.RequestHandler):
    @decorator.oauth_required
    def get(self):
        self.response.headers['Content-Type'] = 'text/plain'
        self.response.out.write('Test page!')
        blogs = service.blogs()
        thisusersblogs = blogs.listByUser(userId='self').execute()
        for blog in thisusersblogs['items']:
            self.response.out.write(pprint.pformat(blog['name']))
            self.response.out.write(pprint.pformat(blog['url']))


def main():
    application = webapp.WSGIApplication([('/myblogs', MainHandler),
                                        (decorator.callback_path,decorator.callback_handler())],
                                         debug=True)
    util.run_wsgi_app(application)


if __name__ == '__main__':
    main()


Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/40193343/calling-blogger-api-using-oauth-2-0
Reply all
Reply to author
Forward
0 new messages