X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/da51b9328abab2df757ed13eadc7c3557315094b..4f1085f353d44600643a8e9dd6b43a39131e7946:/sdk/python/arvados/api.py diff --git a/sdk/python/arvados/api.py b/sdk/python/arvados/api.py index 4413167c31..699c319651 100644 --- a/sdk/python/arvados/api.py +++ b/sdk/python/arvados/api.py @@ -19,6 +19,10 @@ class CredentialsFromEnv(object): from httplib import BadStatusLine if 'headers' not in kwargs: kwargs['headers'] = {} + + if config.get("ARVADOS_EXTERNAL_CLIENT", "") == "true": + kwargs['headers']['X-External-Client'] = '1' + kwargs['headers']['Authorization'] = 'OAuth2 %s' % config.get('ARVADOS_API_TOKEN', 'ARVADOS_API_TOKEN_not_set') try: return self.orig_http_request(uri, **kwargs) @@ -55,13 +59,13 @@ def http_cache(data_type): path = None return path -def api(version=None): +def api(version=None, cache=True): global services if 'ARVADOS_DEBUG' in config.settings(): logging.basicConfig(level=logging.DEBUG) - if not services.get(version): + if not cache or not services.get(version): apiVersion = version if not version: apiVersion = 'v1' @@ -80,12 +84,12 @@ def api(version=None): ca_certs = None # use httplib2 default http = httplib2.Http(ca_certs=ca_certs, - cache=http_cache('discovery')) + cache=(http_cache('discovery') if cache else None)) http = credentials.authorize(http) if re.match(r'(?i)^(true|1|yes)$', config.get('ARVADOS_API_HOST_INSECURE', 'no')): http.disable_ssl_certificate_validation=True services[version] = apiclient.discovery.build( 'arvados', apiVersion, http=http, discoveryServiceUrl=url) + http.cache = None return services[version] -