コード例 #1
0
 def get(self):
     settings = model.show_settings()
     self.as_json({
         'username': settings.username,
         'password': settings.password,
         'config': settings.config,
     })
コード例 #2
0
 def get(self):
     settings = model.show_settings()
     self.as_json({
         'client_id': settings.client_id,
         'api_key': settings.api_key,
         'parent_folder_id': settings.parent_folder_id,
         'filters': settings.filters,
     })
コード例 #3
0
    def get(self):
        settings = model.show_settings()

        template_values = {
            'CLIENT_ID': settings.client_id,
            'API_KEY': settings.api_key,
            'PARENT_FOLDER_ID': settings.parent_folder_id,
            'FILTERS': settings.filters
        }
        path = os.path.join(os.path.dirname(__file__), 'app', 'index.html')
        output = template.render(path, template_values)
        self.response.write(output)
コード例 #4
0
    def post(self):
        data = json.loads(self.request.body)
        settings = model.show_settings()
        config = json.loads(settings.config)
        config_web = config.get('web', {})
        client_id = config_web.get('client_id', '')
        client_secret = config_web.get('client_secret', '')

        credentials = client.credentials_from_code(
            client_id, client_secret,
            ['https://www.googleapis.com/auth/dfatrafficking'], data['code'])
        project = model.create_project(data['name'], data['profileId'],
                                       credentials.to_json())
        self.as_json(as_dict(project))
コード例 #5
0
    def get(self):
        settings = model.show_settings()
        config = json.loads(settings.config)
        client_id = config.get('web', {}).get('client_id', '')

        auth = self.request.authorization
        if auth is None or not check_auth(auth, settings.username,
                                          settings.password):
            self.response.status_int = 401
            self.response.headers[
                'WWW-Authenticate'] = 'Basic realm="Login Required"'
            return

        template_values = {
            'CLIENT_ID': client_id,
        }
        path = os.path.join(os.path.dirname(__file__), 'frontend',
                            'index.html')
        output = template.render(path, template_values)
        self.response.write(output)