3
$\begingroup$

When I use URLRead

Mathematica will popup a window like:

Actually I have given the parameters Password and Username in HTTPRequest, but they seem invalid. Any programmatic method to fill this form so it won't popup?

$\endgroup$
0

1 Answer 1

3
$\begingroup$

V11 update

For new functions it is enough to use documented Interactive option:

URLRead["https://httpbin.org/status/401", Interactive -> False]

Broken for URLDownload so here's a workaround:

Authentication dialog for URLDownload / URLSave


Pre V11 era, URLFetch and friends solutions

There is an undocumented option DisplayProxyDialog which prevents that:

URLFetch[
    "https://httpbin.org/status/401"
  , "StatusCode"
  , "DisplayProxyDialog" -> False
]

As OP noticed it works for URLRead even though it does not appear in Options[URLRead] in contrary to Options[URLFetch].

When switched off you can handle 401 status code however you like, abort, prompt custom dialog etc.


I have not guessed it, WRI Support suggested it to my friend when he asked:

[...] Just informed by our development group that there is such an option (all-be-it undocumented):

"DisplayProxyDialog" -> False

to omit the authentication dialog. [...]

So I suppose this makes it safe to use.

$\endgroup$
3
  • $\begingroup$ Would you mind tell me how did you find it?And actually I prefer to fill out this form than forbid its present. $\endgroup$ Commented Oct 18, 2016 at 20:08
  • $\begingroup$ @yode source added. you can create a loop to ask a user to feed credentials to your dialog and redo the call, or something like that. $\endgroup$ Commented Oct 19, 2016 at 3:38
  • $\begingroup$ This method solve the problem eventually. $\endgroup$ Commented Oct 21, 2016 at 5:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.