Exemplo n.º 1
0
 def get(self):
     access_token = accesstokenservice.get_token(userservice.get_logged_username(self.request))
     if access_token:
         if self.request.get('list'):
             json_vids = get_video_list(access_token)
             self.write(json_vids)
         else:
             self.write(json.dumps(get_video_articles(access_token), indent=3))
     else:
         self.write('No token')
Exemplo n.º 2
0
    def get(self):
        username = userservice.get_logged_username(self.request)

        if username:
            self.response.headers['Content-Type'] = 'text/plain'
            self.response.write('Hello, ' + username)
        else:
            logging.info("uri: " + self.request.uri)
            login_url = userservice.get_login_url(self.request.uri)
            self.redirect(login_url)
Exemplo n.º 3
0
    def get(self):
        #user must be logged with google credentials
        user = userservice.get_logged_username(self.request)

        global code
        redirect_uri_redirect = redirect_uri + self.request.get('post_redirect')
        code = httpcli.doRequest(consumer_key, redirect_uri_redirect)
        logging.info('code: ' + code)

        login_url = httpcli.getLoginUrl(redirect_uri_redirect, code)

        logging.info('login_url: ' + login_url)

        return self.redirect(login_url)
Exemplo n.º 4
0
    def render_logged(self, template, **kw):
        user = None
        try:
            user = userservice.get_logged_username(self.request)
        except Exception:
            logging.debug(Exception.message)

        #TODO cache login url and logout url for each page
        login_url = userservice.get_login_url(self.request.uri)
        logout_url = userservice.get_logout_url(self.request.uri)

        kw['user'] = user
        kw['logout_url'] = logout_url
        kw['login_url'] = login_url
        logging.info('user: ' + str(user))
        return self.write(self.render_str(template, **kw))
Exemplo n.º 5
0
    def get(self):
        access_token = accesstokenservice.get_token(userservice.get_logged_username(self.request))

        if access_token:
            videos = get_video_articles(access_token)
            vids_for_cast = get_video_list(access_token)
            offset = None
            if self.request.get('offset'):
                logging.info('we got offset')
                offset = self.request.get('offset')

                #TODO create a function

            self.render_logged(
                "youtube.html",
                vids=json.dumps(videos),
                vids_for_cast=json.dumps(vids_for_cast),
                offset=offset)
        else:
            #TODO pass parameter to redirect to
            self.redirect('/do-pocket-oauth2' + '?post_redirect=' + '/pocket-playlist')
Exemplo n.º 6
0
 def get_logged_token(self):
     return accesstokenservice.get_token(userservice.get_logged_username(self.request))
Exemplo n.º 7
0
 def get(self):
     access_token = accesstokenservice.get_token(userservice.get_logged_username(self.request))
     if access_token:
         self.render("./cast/feedvids-cast-sender.html", vids=json.dumps(get_video_list(access_token)))
     else:
         self.write('No token')