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, flags=args)

    copy_json(client_secret, secret_path)

    with open('./creds/ga.json', 'w+') as f:
        credentials = {
            "CLIENT_SECRETS": secret_path,
            "STORAGE_PATH": storage_path,
        }
        json.dump(credentials, f, indent=2)
def generate_stuff(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

    storage_path = abspath("./config/storage.db")
    secret_path = abspath("./config/client_secret.json")
    from_secrets_file(client_secret, storage_path=storage_path)

    copy_json(client_secret, secret_path)

    with open('./config/credentials.json', 'w+') as f:
        credentials = {
            "CLIENT_SECRETS": secret_path,
            "STORAGE_PATH": storage_path,
        }
        json.dump(credentials, f, indent=2)
def generate_stuff(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

    storage_path = abspath("./config/storage.db")
    secret_path = abspath("./config/client_secret.json")
    from_secrets_file(
        client_secret,
        storage_path=storage_path)

    copy_json(client_secret, secret_path)

    with open('./config/credentials.json', 'w+') as f:
        credentials = {
            "CLIENT_SECRETS": secret_path,
            "STORAGE_PATH": storage_path,
        }
        json.dump(credentials, f, indent=2)
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,
        flags=args)

    copy_json(client_secret, secret_path)

    with open('./creds/ga.json', 'w+') as f:
        credentials = {
            "CLIENT_SECRETS": secret_path,
            "STORAGE_PATH": storage_path,
        }
        json.dump(credentials, f, indent=2)
Пример #5
0
def _create_client(credentials):
    if "CLIENT_SECRETS" in credentials:
        return from_secrets_file(
            credentials['CLIENT_SECRETS'],
            storage_path=credentials['STORAGE_PATH']

        )
    else:
        return from_private_key(
            credentials['ACCOUNT_NAME'],
            private_key_path=credentials['PRIVATE_KEY'],
            storage_path=credentials['STORAGE_PATH']
        )
Пример #6
0
def _create_client(credentials):
    if "CLIENT_SECRETS" in credentials:
        return from_secrets_file(
            credentials['CLIENT_SECRETS'],
            storage_path=credentials['STORAGE_PATH']

        )
    else:
        return from_private_key(
            credentials['ACCOUNT_NAME'],
            private_key_path=credentials['PRIVATE_KEY'],
            storage_path=credentials['STORAGE_PATH']
        )
def create_client(credentials):
    if "CLIENT_SECRETS" in credentials:
        return from_secrets_file(
            credentials['CLIENT_SECRETS'],
            storage_path=credentials['STORAGE_PATH'],
            http_client=HttpWithBackoff(),
            ga_hook=track_ga_api_usage,
        )
    else:
        return from_private_key(
            credentials['ACCOUNT_NAME'],
            private_key_path=credentials['PRIVATE_KEY'],
            storage_path=credentials['STORAGE_PATH'],
            http_client=HttpWithBackoff(),
            ga_hook=track_ga_api_usage,
        )
def create_client(credentials):
    if "CLIENT_SECRETS" in credentials and "STORAGE_PATH" in credentials:
        return from_secrets_file(
            credentials['CLIENT_SECRETS'],
            storage_path=credentials['STORAGE_PATH'],
            http_client=HttpWithBackoff(),
            ga_hook=track_ga_api_usage,
        )
    elif "ACCOUNT_NAME" in credentials:
        return from_private_key(
            credentials['ACCOUNT_NAME'],
            private_key_path=credentials['PRIVATE_KEY'],
            storage_path=credentials['STORAGE_PATH'],
            http_client=HttpWithBackoff(),
            ga_hook=track_ga_api_usage,
        )
    else:
        return from_credentials_db(
            credentials['CLIENT_SECRETS']['installed'],
            credentials['OAUTH2_CREDENTIALS'],
            http_client=HttpWithBackoff(),
            ga_hook=track_ga_api_usage,
        )