def get(self): currentUser = users.get_current_user() if currentUser: self.response.headers['Content-Type'] = 'text/html' self.blogger = gdata.blogger.service.BloggerService() gdata.alt.appengine.run_on_appengine(self.blogger) authTok = gdata.auth.extract_auth_sub_token_from_url(self.request.uri) self.blogger.SetAuthSubToken(authTok) self.blogger.UpgradeToSessionToken(authTok) self.blogger.SetAuthSubToken(authTok.get_token_string()) sessionTok = self.blogger.GetAuthSubToken() # DEBUG ONLY: # self.response.out.write('Updated AuthTok= %s, SessionTok = %s' % (authTok, sessionTok)) feed = self.blogger.GetBlogFeed() template_values = { 'title': feed.title.text, 'entries': feed.entry, } path = os.path.join(os.path.dirname(__file__), 'auth.html') self.response.out.write(template.render(path, template_values)) userStuff = UserStuff() userStuff.user = currentUser userStuff.authToken = authTok.get_token_string() userStuff.put() else: self.redirect(users.create_login_url(self.request.uri))
def get(self): self.response.headers['Content-Type'] = 'text/html' currentUser = users.get_current_user() if currentUser: query = UserStuff.all() query.filter('user ='******'blogid') buzzFeedUrl = FetchBuzzApiUrl(currentUser.email()) subscribeResponseCode = SubscribePubsubHubbub(buzzFeedUrl) if 202 == subscribeResponseCode: self.response.out.write('PubSubHubbub Subscribe succeeded for feed %s.<br/>' % buzzFeedUrl) if updatedBlogId: userStuff.blogId = updatedBlogId userStuff.buzzFeed = buzzFeedUrl userStuff.put() self.response.out.write('<div>Set BlogId</div>') # no longer echo the token as it's 'secure' self.response.out.write('All done. You can close this app now.') self.response.out.write('<br/>Debug info: user %s, blogId %s' % (userStuff.user.email(), userStuff.blogId)) else: self.redirect(users.create_login_url(self.request.uri))