Beispiel #1
0
    def __init__(self, consumer_key, consumer_secret, locale=None):
        self.consumer_key = consumer_key
        self.consumer_secret = consumer_secret
        self.locale = locale
        self.session = pinned_session()

        self._domain = os.environ.get('DROPBOX_DOMAIN', Dropbox.DEFAULT_DOMAIN)
Beispiel #2
0
    def __init__(self,
                 oauth2_access_token,
                 max_connections=8,
                 max_retries_on_error=4,
                 user_agent=None):
        """
        :param str oauth2_access_token: OAuth2 access token for making client requests.
        :param int max_connections: Maximum connection pool size.
        :param int max_retries_on_error: On 5xx errors, the number of times to retry.
        :param str user_agent: The user agent to use when making requests. This helps
            us identify requests coming from your application. We recommend you use
            the format "AppName/Version". If set, we append
            "/OfficialDropboxPythonV2SDK/__version__" to the user_agent,
        """
        self._oauth2_access_token = oauth2_access_token

        # We only need as many pool_connections as we have unique hostnames.
        self._session = pinned_session(pool_maxsize=max_connections)
        self._max_retries_on_error = max_retries_on_error

        base_user_agent = 'OfficialDropboxPythonV2SDK/' + __version__
        if user_agent:
            self._user_agent = '{}/{}'.format(user_agent, base_user_agent)
        else:
            self._user_agent = base_user_agent

        self._logger = logging.getLogger('dropbox')

        self._domain = os.environ.get('DROPBOX_DOMAIN', Dropbox.DEFAULT_DOMAIN)
        self._api_hostname = os.environ.get(
            'DROPBOX_API_HOST', 'api.' + self._domain)
        self._api_content_hostname = os.environ.get(
            'DROPBOX_API_CONTENT_HOST', 'api-content.' + self._domain)
        self._host_map = {self.HOST_API: self._api_hostname,
                          self.HOST_CONTENT: self._api_content_hostname}