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()