def on_profile_response(self, response):
        """Handles user profile request response."""
        if response.error:
            self.send_error()
            
        try:
            github_user = json.loads(response.body)
        except:
            logging.exception('Failed to decode response.')
            self.send_error()
        
        user_id = None
        current_user = User.objects(service='github', nick=github_user['login']).first()
        if current_user != None:
            user_id = unicode(current_user.id)
            logging.info('GitHub user "%s" already signed up.' % (github_user['login'], ))
        else:    
            user = User(service='github', nick=github_user['login'], url=github_user['html_url'], avatar_url=github_user['avatar_url'])
            
            logging.info((github_user['login'], ) % 'Saving GitHub user "%s".')
            try:
                user.save()
            except:
                logging.exception('Failed to save user in DB.')
                self.send_error()
                
            user_id = unicode(user.id)
            
        self.set_secure_cookie('user_id', user_id, expires_days=365)
        self.redirect('/#publish')
        self.finish()
dataset/ETHPy150Open tomekwojcik/iheartgit/iheartgit/handlers/oauth.py/GitHubCallbackHandler.on_profile_response/swapped operands of `%`