23
23
import six
24
24
import base64
25
25
import requests
26
+ from requests .auth import HTTPBasicAuth
26
27
27
28
if sys .version [:1 ] == '2' :
28
29
from urlparse import urlparse
@@ -586,25 +587,22 @@ def get(figure_or_data, format='png', width=None, height=None):
586
587
credentials = get_credentials ()
587
588
validate_credentials (credentials )
588
589
username , api_key = credentials ['username' ], credentials ['api_key' ]
589
- headers = {'plotly-username' : username ,
590
- 'plotly-apikey' : api_key ,
591
- 'plotly-version' : version .__version__ ,
592
- 'plotly-platform' : 'python' }
593
-
594
- payload = {
595
- 'figure' : figure ,
596
- 'format' : format
597
- }
590
+ headers = {'Plotly-Version' : version .__version__ ,
591
+ 'Content-Type' : 'application/json' ,
592
+ 'Plotly-Client-Platform' : 'python' }
598
593
594
+ payload = {'figure' : figure , 'format' : format }
599
595
if width is not None :
600
596
payload ['width' ] = width
601
597
if height is not None :
602
598
payload ['height' ] = height
603
599
604
- url = get_config ()['plotly_domain' ] + "/apigenimage/"
600
+ url = _api_v2 .api_url ('images/' )
601
+
605
602
res = requests .post (
606
603
url , data = json .dumps (payload , cls = utils .PlotlyJSONEncoder ),
607
- headers = headers , verify = get_config ()['plotly_ssl_verification' ]
604
+ headers = headers , verify = get_config ()['plotly_ssl_verification' ],
605
+ auth = HTTPBasicAuth (username , api_key )
608
606
)
609
607
610
608
headers = res .headers
0 commit comments