I'm using goobook as a command-line Google Contacts query tool, using the instructions provided here to create a client on the cloud console and then authenticate from the command-line (using a headless session). The token only lasts a few days and then the tools needs re-authentication. I don't see a setting in the Google Cloud Console to lengthen the token expiration time -- is this something I need to change in the goobook code, in the cloud console, or somewhere else?
Running the tool every hour to keep the token fresh does not help.
Per a comment, the command I am using is:
goobook authenticate --noauth_local_webserver -- [CLIENT ID] [CLIENT SECRET]
The goobook authentication code (which I did not write) is here, I believe in relevant part:
import oauth2client.client
import oauth2client.file
import oauth2client.tools
...
parser_auth = subparsers.add_parser('authenticate',
description=AUTHENTICATE_HELP_STRING,
formatter_class=argparse.RawDescriptionHelpFormatter,
parents=[oauth2client.tools.argparser])
parser_auth.add_argument('client_id', metavar='CLIENT_ID',
help='Client ID')
parser_auth.add_argument('client_secret', metavar='CLIENT_SECRET',
help='Client secret')
parser_auth.set_defaults(func=do_authenticate)
...
def do_authenticate(config, args):
store = config.store
creds = config.creds
if not creds or creds.invalid:
flow = oauth2client.client.OAuth2WebServerFlow(args.client_id, args.client_secret, SCOPES)
creds = oauth2client.tools.run_flow(flow, store, args)
else:
print('You are already authenticated.')