Skip to content

Commit a9f0c95

Browse files
committed
error message that catches responses with HTTP and not HTTPS
1 parent e932378 commit a9f0c95

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

plotly/api/v2/utils.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,37 @@
88
from plotly.api.utils import basic_auth
99

1010

11+
HTTP_ERROR_MESSAGE = (
12+
"""Your plotly_domain and plotly_api_domain must be HTTPS and not HTTP.\n
13+
If you are not using On-Prem then run the following code to ensure your
14+
plotly_domain and plotly_api_domain start with 'https':
15+
16+
```
17+
import plotly
18+
plotly.tools.set_config_file(
19+
plotly_domain='https://plot.ly',
20+
plotly_api_domain='https://api.plot.ly'
21+
)
22+
```
23+
24+
If you are using On-Prem then you will need to use your company's
25+
domain and api_domain urls:
26+
27+
```
28+
import plotly
29+
plotly.tools.set_config_file(
30+
plotly_domain='https://plotly.your-company.com',
31+
plotly_api_domain='https://plotly.your-company.com'
32+
)
33+
```
34+
35+
Make sure to replace "your-company.com" with the URL of your Plotly On-Premise server.
36+
37+
See https://plot.ly/python/getting-started/#special-instructions-for-plotly-onpremise-users
38+
for more tips for getting started with Plotly."""
39+
)
40+
41+
1142
def make_params(**kwargs):
1243
"""
1344
Helper to create a params dict, skipping undefined entries.
@@ -76,6 +107,10 @@ def validate_response(response):
76107
if not message:
77108
message = content if content else 'No Content'
78109

110+
if not response.history[0].url.startswith('https:'):
111+
raise exceptions.PlotlyRequestError(HTTP_ERROR_MESSAGE,
112+
status_code, content)
113+
79114
raise exceptions.PlotlyRequestError(message, status_code, content)
80115

81116

0 commit comments

Comments
 (0)