Skip to content
This repository has been archived by the owner on Mar 24, 2021. It is now read-only.

Commit

Permalink
Call from_secrets_file with a 'flags' argument
Browse files Browse the repository at this point in the history
from_secrets_file uses a run_flow method from
the oauth2client library and this method now
requires a flags argument.
  • Loading branch information
leelongmore committed Feb 4, 2016
1 parent b54f75f commit dd3f471
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ pytz==2013d
argparse
python-dateutil
logstash_formatter
gapy==1.3.3
gapy==1.3.4
lxml>=3.2.0
dshelpers>=1.0.4
unicodecsv
Expand Down
22 changes: 13 additions & 9 deletions tools/generate-ga-credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
from os.path import abspath, exists as path_exists
from os import makedirs

from oauth2client import tools

from gapy.client import from_secrets_file
import oauth2client.tools


def copy_json(input_path, output_path):
Expand All @@ -30,18 +31,16 @@ def copy_json(input_path, output_path):
indent=2)


def generate_google_credentials(client_secret):
# Prevent oauth2client from trying to open a browser
# This is run from inside the VM so there is no browser
oauth2client.tools.FLAGS.auth_local_webserver = False

def generate_google_credentials(args):
client_secret = args.client_secret
if not path_exists(abspath("./creds/ga/")):
makedirs("./creds/ga")
storage_path = abspath("./creds/ga/storage.db")
secret_path = abspath("./creds/ga/client_secret.json")
from_secrets_file(
client_secret,
storage_path=storage_path)
storage_path=storage_path,
flags=args)

copy_json(client_secret, secret_path)

Expand All @@ -56,12 +55,17 @@ def generate_google_credentials(client_secret):
if __name__ == '__main__':
parser = argparse.ArgumentParser(
description=__doc__,
formatter_class=argparse.RawTextHelpFormatter)
formatter_class=argparse.RawTextHelpFormatter,
parents=[tools.argparser])

parser.add_argument(
'client_secret',
help='path to the client secrets file from the Google API Console')

args = parser.parse_args()

generate_google_credentials(args.client_secret)
# This script is run from within the VM so
# disable need for a browser
args.noauth_local_webserver = True

generate_google_credentials(args)

0 comments on commit dd3f471

Please sign in to comment.