How to read email of facebook user using Facebook graph api for python-tornado?
I have included 'email' in extended parameters scope. How do I read the email in a tornado object?

My LoginHandler looks like this:

    class LoginHandler(tornado.web.RequestHandler, tornado.auth.FacebookGraphMixin):
        @tornado.web.asynchronous
        def get(self):
            userID = self.get_secure_cookie('user_id')
        
            if self.get_argument('code', None):
                self.get_authenticated_user(
                    redirect_uri='http://localhost:8000/auth/login',
                    client_id=self.settings['facebook_api_key'],
                    client_secret=self.settings['facebook_secret'],
                    code=self.get_argument('code'),
                    callback=self.async_callback(self._on_facebook_login))
            
                return
            elif self.get_secure_cookie('access_token'):
                self.redirect('/')
                return
        
            self.authorize_redirect(
                redirect_uri='http://localhost:8000/auth/login',
                client_id=self.settings['facebook_api_key'],
                extra_params={'scope': 'email'}
            )

        def _on_facebook_login(self, user):
            if not user:
                self.clear_all_cookies()
                raise tornado.web.HTTPError(500, 'Facebook authentication failed')
        
            self.set_secure_cookie('user_id', str(user['id']))
            self.set_secure_cookie('user_name', str(user['name']))
            self.set_secure_cookie('access_token', str(user['access_token']))
            self.redirect('/')

I need to collect the email in an object and insert it into the database.

How to read email of facebook user using Facebook graph api for python-tornado?
===

I have included 'email' in extended parameters scope. How do I read the email in a tornado object?

My LoginHandler looks like this:

    class LoginHandler(tornado.web.RequestHandler, tornado.auth.FacebookGraphMixin):
        @tornado.web.asynchronous
        def get(self):
            userID = self.get_secure_cookie('user_id')
        
            if self.get_argument('code', None):
                self.get_authenticated_user(
                    redirect_uri='http://localhost:8000/auth/login',
                    client_id=self.settings['facebook_api_key'],
                    client_secret=self.settings['facebook_secret'],
                    code=self.get_argument('code'),
                    callback=self.async_callback(self._on_facebook_login))
            
                return
            elif self.get_secure_cookie('access_token'):
                self.redirect('/')
                return
        
            self.authorize_redirect(
                redirect_uri='http://localhost:8000/auth/login',
                client_id=self.settings['facebook_api_key'],
                extra_params={'scope': 'email'}
            )

        def _on_facebook_login(self, user):
            if not user:
                self.clear_all_cookies()
                raise tornado.web.HTTPError(500, 'Facebook authentication failed')
        
            self.set_secure_cookie('user_id', str(user['id']))
            self.set_secure_cookie('user_name', str(user['name']))
            self.set_secure_cookie('access_token', str(user['access_token']))
            self.redirect('/')

I need to collect the email in an object and insert it into the database.
