예제 #1
0
    def facebook_callback(self):
        log.info("Redirected")
        log.info(self.request.user)
        user = self.request.user

        user_entity = User.get_by_id(user.get("id"))

        if not user_entity:

            new_user = OauthUser(id=user.get("id"))
            new_user.name = user.get("name")
            new_user.email_id = user.get("email")
            new_user.picture_url = user.get("picture", {}) \
                                       .get("data", {})    \
                                       .get("url")
            new_user.oauth_type = "facebook"
            new_user.profile_url = "https://facebook.com/{}".format(user.get("id"))
            new_user.token = str(uuid4())
            new_user.put()

        token = get_token(value=user.get("id"))

        self.response.set_cookie("token", token, max_age=24*3600)

        self.redirect('/dashboard#')
예제 #2
0
    def google_callback(self):
        log.info("Redirected")

        user = self.request.user

        user_entity = User.get_by_id(user.get("id"))

        if not user_entity:
            new_user = OauthUser(id=user.get("id"))
            new_user.name = user.get("name")
            new_user.email_id = user.get("email")
            new_user.picture_url = user.get("picture")
            new_user.profile_url = user.get("link")
            new_user.oauth_type = "google"
            new_user.token = str(uuid4())
            new_user.put()

        token = get_token(value=user.get("id"))

        self.response.set_cookie("token", token, max_age=24*3600)

        self.redirect('/dashboard#')