File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -1320,7 +1320,7 @@ def validate_credentials(credentials):
1320
1320
raise exceptions .PlotlyLocalCredentialsError ()
1321
1321
1322
1322
1323
- def add_share_key_to_url (plot_url ):
1323
+ def add_share_key_to_url (plot_url , attempt = 0 ):
1324
1324
"""
1325
1325
Update plot's url to include the secret key
1326
1326
@@ -1343,8 +1343,19 @@ def add_share_key_to_url(plot_url):
1343
1343
str_content = new_response .content .decode ('utf-8' )
1344
1344
1345
1345
new_response_data = json .loads (str_content )
1346
+
1346
1347
plot_url += '?share_key=' + new_response_data ['share_key' ]
1347
1348
1349
+ # sometimes a share key is added, but access is still denied
1350
+ # check for access, and retry a couple of times if this is the case
1351
+ embed_url = plot_url .split ('?' )[0 ] + '.embed' + plot_url .split ('?' )[1 ]
1352
+ access_res = requests .get (embed_url )
1353
+ if access_res .status_code == 404 :
1354
+ attempt += 1
1355
+ if attempt == 5 :
1356
+ break
1357
+ plot_url = add_share_key_to_url (plot_url .split ('?' )[0 ], attempt )
1358
+
1348
1359
return plot_url
1349
1360
1350
1361
You can’t perform that action at this time.
0 commit comments