summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/services/__init__.py
diff options
context:
space:
mode:
authorTomás Touceda <chiiph@leap.se>2013-10-02 11:57:57 -0300
committerTomás Touceda <chiiph@leap.se>2013-10-02 13:06:14 -0300
commit5b2220bc0177f12c81a3dbb1ebffd3cdae8b350d (patch)
tree01786cd567dd61ef84c2eec50bab42099ef16b5f /src/leap/bitmask/services/__init__.py
parent8f55c9670a0547bc4879d2b36affbffbf201e4fc (diff)
Use token header also for authenticated requests
Diffstat (limited to 'src/leap/bitmask/services/__init__.py')
-rw-r--r--src/leap/bitmask/services/__init__.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/leap/bitmask/services/__init__.py b/src/leap/bitmask/services/__init__.py
index 0d74e0e2..e19b82b9 100644
--- a/src/leap/bitmask/services/__init__.py
+++ b/src/leap/bitmask/services/__init__.py
@@ -127,10 +127,15 @@ def download_service_config(provider_config, service_config,
# XXX make and use @with_srp_auth decorator
srp_auth = SRPAuth(provider_config)
session_id = srp_auth.get_session_id()
+ token = srp_auth.get_token()
cookies = None
- if session_id:
+ if session_id is not None:
cookies = {"_session_id": session_id}
+ # API v2 will only support token auth, but in v1 we can send both
+ if token is not None:
+ headers["Authorization"] = 'Token token="{0}"'.format(token)
+
res = session.get(config_uri,
verify=provider_config.get_ca_cert_path(),
headers=headers,