Skip to content

Commit 5139385

Browse files
committed
Move from genimage —> v2/images/
1 parent ce0adcc commit 5139385

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

Diff for: plotly/plotly/plotly.py

+9-11
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import six
2525
import base64
2626
import requests
27+
from requests.auth import HTTPBasicAuth
2728

2829
if sys.version[:1] == '2':
2930
from urlparse import urlparse
@@ -582,25 +583,22 @@ def get(figure_or_data, format='png', width=None, height=None):
582583
credentials = get_credentials()
583584
validate_credentials(credentials)
584585
username, api_key = credentials['username'], credentials['api_key']
585-
headers = {'plotly-username': username,
586-
'plotly-apikey': api_key,
587-
'plotly-version': version.__version__,
588-
'plotly-platform': 'python'}
589-
590-
payload = {
591-
'figure': figure,
592-
'format': format
593-
}
586+
headers = {'Plotly-Version': version.__version__,
587+
'Content-Type': 'application/json',
588+
'Plotly-Client-Platform': 'python'}
594589

590+
payload = {'figure': figure, 'format': format}
595591
if width is not None:
596592
payload['width'] = width
597593
if height is not None:
598594
payload['height'] = height
599595

600-
url = get_config()['plotly_domain'] + "/apigenimage/"
596+
url = _api_v2.api_url('images/')
597+
601598
res = requests.post(
602599
url, data=json.dumps(payload, cls=utils.PlotlyJSONEncoder),
603-
headers=headers, verify=get_config()['plotly_ssl_verification']
600+
headers=headers, verify=get_config()['plotly_ssl_verification'],
601+
auth=HTTPBasicAuth(username, api_key)
604602
)
605603

606604
headers = res.headers

0 commit comments

Comments
 (0)