From 51393859094ade6b998b26385ad089fbdf5db9c0 Mon Sep 17 00:00:00 2001 From: Andrew Seier Date: Sat, 7 Mar 2015 20:02:46 -0800 Subject: [PATCH] =?UTF-8?q?Move=20from=20genimage=20=E2=80=94>=20v2/images?= =?UTF-8?q?/?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plotly/plotly/plotly.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/plotly/plotly/plotly.py b/plotly/plotly/plotly.py index b2e44e19ce0..9bc75d8dfe2 100644 --- a/plotly/plotly/plotly.py +++ b/plotly/plotly/plotly.py @@ -24,6 +24,7 @@ import six import base64 import requests +from requests.auth import HTTPBasicAuth if sys.version[:1] == '2': from urlparse import urlparse @@ -582,25 +583,22 @@ def get(figure_or_data, format='png', width=None, height=None): credentials = get_credentials() validate_credentials(credentials) username, api_key = credentials['username'], credentials['api_key'] - headers = {'plotly-username': username, - 'plotly-apikey': api_key, - 'plotly-version': version.__version__, - 'plotly-platform': 'python'} - - payload = { - 'figure': figure, - 'format': format - } + headers = {'Plotly-Version': version.__version__, + 'Content-Type': 'application/json', + 'Plotly-Client-Platform': 'python'} + payload = {'figure': figure, 'format': format} if width is not None: payload['width'] = width if height is not None: payload['height'] = height - url = get_config()['plotly_domain'] + "/apigenimage/" + url = _api_v2.api_url('images/') + res = requests.post( url, data=json.dumps(payload, cls=utils.PlotlyJSONEncoder), - headers=headers, verify=get_config()['plotly_ssl_verification'] + headers=headers, verify=get_config()['plotly_ssl_verification'], + auth=HTTPBasicAuth(username, api_key) ) headers = res.headers