Пример #1
0
    def get(self):
        cookie = Cookies(self, settings.COOKIE_SECRET)
        id = cookie.get_secure_cookie(name = "ig_user_id")
        profile = Profile.all().filter('ig_user_id =', id).get()

        if profile: profile.delete()
        self.redirect('/')
Пример #2
0
    def get(self):
        cookie = Cookies(self, settings.COOKIE_SECRET)
        id = cookie.get_secure_cookie(name = "ig_user_id")
        profile = Profile.all().filter('ig_user_id =', id).get()

        if profile and profile.is_connected():
            self.redirect('/')
        else: self.redirect('/instagram/auth')
Пример #3
0
    def get(self):
        cookie = Cookies(self, settings.COOKIE_SECRET)
        id = cookie.get_secure_cookie(name = "ig_user_id")
        profile = Profile.all().filter('ig_user_id =', id).get()
        context  = {}

        if profile and profile.is_connected():
            template = 'connected.html'
            context  = {
                'profile': profile,
                'ig_user_id': id,
            }
        else: template = 'disconnected.html'
        self.render_template(template, context)
Пример #4
0
    def get(self):
        code = self.request.get('code')
        token = _api.exchange_code_for_access_token(code)
        if not token: self.redirect('/error')

        client = Client(access_token=token)
        user = client.user('self')
        profile = Profile.all().filter('ig_user_id = ', user.id)
        profile = (profile.get() or Profile())

        profile.full_name = (user.fullname or user.username)
        profile.ig_user_id = user.id
        profile.ig_username = user.username
        profile.ig_access_token = access_token
        profile.put()

        cookie = Cookies(self, settings.COOKIE_SECRET)
        cookie.set_secure_cookie(name = 'ig_user_id',
            value = user.id, expires_days = 365)

        self.redirect('/connect')