google-auth-library-python-oauthlib icon indicating copy to clipboard operation
google-auth-library-python-oauthlib copied to clipboard

It should be possible to control printed messages, e.g. in class `Flow`

Open arnauldvm opened this issue 3 years ago • 1 comments

Is your feature request related to a problem? Please describe.

In command line tools that are processing data automatically, I want to be in control of what goes to STDOUT. It is not possible because of methods writing spontaneously on STDOUT (how bad mannered is it ;-)). Typically, the methods run_console and run_local_server of the class Flow.

Describe the solution you'd like

  • Either: add a flag to these methods to disable the print
  • Or: add a parameter to these methods so that the invoker may provide the output stream to write the message to (sys.stdin : same as now, sys.stderr: STDERR, None: disable...)

(Note: other methods invoking them should also provide such parameters.)

Alternatively, the flag/parameter could be set globally.

Describe alternatives you've considered

Adding a | grep -v 'Please visit this URL to authorize this application' after my script.

Ugly.

from contextlib import redirect_stdout
...
    with redirect_stdout(sys.stderr):
        ...

Slightly better.

Additional context

(There might be other classes than Flow with the same problem. Didn't check.)

arnauldvm avatar Jan 15 '22 12:01 arnauldvm

setting p3 for the future request

arithmetic1728 avatar Mar 30 '22 20:03 arithmetic1728