|
24 | 24 | import six
|
25 | 25 | import base64
|
26 | 26 | import requests
|
| 27 | +from requests.auth import HTTPBasicAuth |
27 | 28 |
|
28 | 29 | if sys.version[:1] == '2':
|
29 | 30 | from urlparse import urlparse
|
@@ -582,25 +583,22 @@ def get(figure_or_data, format='png', width=None, height=None):
|
582 | 583 | credentials = get_credentials()
|
583 | 584 | validate_credentials(credentials)
|
584 | 585 | 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'} |
594 | 589 |
|
| 590 | + payload = {'figure': figure, 'format': format} |
595 | 591 | if width is not None:
|
596 | 592 | payload['width'] = width
|
597 | 593 | if height is not None:
|
598 | 594 | payload['height'] = height
|
599 | 595 |
|
600 |
| - url = get_config()['plotly_domain'] + "/apigenimage/" |
| 596 | + url = _api_v2.api_url('images/') |
| 597 | + |
601 | 598 | res = requests.post(
|
602 | 599 | 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) |
604 | 602 | )
|
605 | 603 |
|
606 | 604 | headers = res.headers
|
|
0 commit comments