Package oauth2client :: Module tools |
[hide private]
[frames] | no frames]

# Module tools

source code

    Command-line tools for authenticating via OAuth 2.0

    Do the OAuth 2.0 Web Server dance for a command line application. Stores the
    generated credentials in a common file that is used by other example apps in
    the same directory.

Author: jcgregorio@google.com (Joe Gregorio)

Classes | [hide private]
| ClientRedirectServer A server to handle OAuth 2.0 redirects back to localhost.
| ClientRedirectHandler A handler for OAuth 2.0 redirects back to localhost.

Functions | [hide private]
run_flow(flow, storage, flags, http=None) Core code for a command-line application. | source code
message_if_missing(filename) Helpful message to display if the CLIENT_SECRETS file is missing. | source code
run(*args, **kwargs) | source code

Variables | [hide private]
| _CLIENT_SECRETS_MESSAGE = `"""WARNING: Please configure OAuth `...``
| argparser = `argparse.ArgumentParser(add_help= False)`

Function Details | [hide private]

### run_flow(flow, storage, flags, http=None) | source code
    Core code for a command-line application.

    The run() function is called from your application and runs through all the
    steps to obtain credentials. It takes a Flow argument and attempts to open an
    authorization server page in the user's default web browser. The server asks
    the user to grant your application access to the user's data. If the user
    grants access, the run() function returns new credentials. The new credentials
    are also stored in the Storage argument, which updates the file associated
    with the Storage object.

    It presumes it is run from a command-line application and supports the
    following flags:

      --auth_host_name: Host name to use when running a local web server
        to handle redirects during OAuth authorization.
        (default: 'localhost')

      --auth_host_port: Port to use when running a local web server to handle
        redirects during OAuth authorization.;
        repeat this option to specify a list of values
        (default: '[8080, 8090]')
        (an integer)

      --[no]auth_local_webserver: Run a local web server to handle redirects
        during OAuth authorization.
        (default: 'true')

    The tools module defines an ArgumentParser the already contains the flag
    definitions that run() requires. You can pass that ArgumentParser to your
    ArgumentParser constructor:

      parser = argparse.ArgumentParser(description=__doc__,
          formatter_class=argparse.RawDescriptionHelpFormatter,
          parents=[tools.run_parser])
      flags = parser.parse_args(argv)

    Args:
      flow: Flow, an OAuth 2.0 Flow to step through.
      storage: Storage, a Storage to store the credential in.
      flags: argparse.ArgumentParser, the command-line flags.
      http: An instance of httplib2.Http.request
           or something that acts like it.

    Returns:
      Credentials, the obtained credential.
Decorators: `@util.positional(3)`

Variables Details | [hide private]

  ### _CLIENT_SECRETS_MESSAGE Value:
      """WARNING: Please configure OAuth 2.0

      To make this sample run you will need to populate the client_secrets.j
      son file
      found at:

         %s

      ...