How to use the ox3apiclient.__init__.UnknownAPIFormatError function in ox3apiclient

To help you get started, we’ve selected a few ox3apiclient examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github openx / OX3-Python-API-Client / ox3apiclient / __init__.py View on Github external
"""Returns self after deleting authenticated session."""
        if self.api_path == API_PATH_V1:
            response = self._session.delete(self._resolve_url('/a/session'), timeout=self.timeout)
        elif self.api_path == API_PATH_V2:
            response = self._session.delete(self._resolve_url('/session'), timeout=self.timeout)
        elif self.api_path == API_PATH_SSO:
            oauth = OAuth1(client_key=self.consumer_key,
                           resource_owner_key=self._token,
                           callback_uri=self.callback_url,
                           signature_type='query')

            response = self._session.delete(url=self.access_token_url, auth=oauth, timeout=self.timeout)
            if response.status_code != 204:
                raise OAuthException("OAuth token deletion failed (%s) %s" % (response.status_code, response.text))
        else:
            raise UnknownAPIFormatError(
                'Unrecognized API path: %s' % self.api_path)
        self.log_request(response)
        return self
github openx / OX3-Python-API-Client / ox3apiclient / __init__.py View on Github external
with open(file_path, 'r') as f:
            parts.append(f.read())

        parts.append('--' + boundary + '--')
        parts.append('')

        body = '\r\n'.join(parts)

        # TODO: Catch errors in attempt to upload.
        headers = {'content-type': 'multipart/form-data; boundary=' + boundary}
        if self.api_path == API_PATH_V1:
            url = self._resolve_url('/a/creative/uploadcreative')
        elif self.api_path == API_PATH_V2:
            url = self._resolve_url('/creative/uploadcreative')
        else:
            raise UnknownAPIFormatError(
                'Unrecognized API path: %s' % self.api_path)
        response = self._session.get(url, headers=headers, data=body, timeout=self.timeout)
        self.log_request(response)
        response.raise_for_status()
        return self._response_value(response)
github openx / OX3-Python-API-Client / ox3apiclient / __init__.py View on Github external
self.consumer_secret = consumer_secret
        self.callback_url = callback_url
        self.scheme = scheme
        self.request_token_url = request_token_url
        self.access_token_url = access_token_url
        self.authorization_url = authorization_url
        self.api_path = api_path
        self.timeout = timeout

        # Validate API path:
        if api_path not in ACCEPTABLE_PATHS:
            msg = '"{}" is not a recognized API path.'.format(api_path)
            msg += '\nLegal paths include:'
            for i in ACCEPTABLE_PATHS:
                msg += '\n{}'.format(i)
            raise UnknownAPIFormatError(msg)

        # These get cleared after log on attempt.
        self._email = email
        self._password = password

        # You shouldn't need to access the token and session objects directly so we'll keep them private.
        self._token = None
        self._session = requests.Session()
        # set supplied headers and proxies
        if headers:
            self._session.headers.update(headers)
        if http_proxy:
            self._session.proxies.update({'http': http_proxy})
        if https_proxy:
            self._session.proxies.update({'https': https_proxy})

ox3apiclient

Client to connect to the OpenX Enterprise API.

BSD-2-Clause
Latest version published 3 years ago

Package Health Score

42 / 100
Full package analysis