By using a Redirect URI of http://localhost
and starting up a local webserver to wait for that redirect. See the code for the tools.run_flow() function in the Google API Python Client library that does this kind of flow:
https://code.google.com/p/google-api-python-client/source/browse/oauth2client/tools.py#110