def main():
    args = parse_args()
    print(args.ca_cert)
    config_file_path = getenv('IMM_CONFIG_PATH', join(expanduser("~"), '.imm'))
    auth_url = get_dex_auth_url(address=args.address,
                                port=args.port,
                                ca_cert_path=args.ca_cert)
    auth_url_with_refresh_token = enable_getting_refresh_token(auth_url)

    auth_url_unparsed = urlparse(auth_url)
    queries = parse_qs(auth_url_unparsed.query)
    redirect_port = urlparse(queries['redirect_uri'][0]).port

    run_server(redirect_port, auth_url_with_refresh_token)
    print('Code recieved, waiting for token.')
    token = get_dex_auth_token(address=args.address,
                               port=args.port,
                               auth_code=code,
                               ca_cert_path=args.ca_cert)
    token.update({
        'management_api_address': args.address,
        'management_api_port': args.port,
        'ca_cert_path': args.ca_cert
    })
    save_to_file(config_file_path, token)
    print("Your token and refresh token are available in file: {}".format(
        config_file_path))
def main():
    config_file_path = getenv('IMM_CONFIG_PATH', join(expanduser("~"), '.imm'))
    config = read_config(config_file_path)
    ca_cert_path = check_cert(config['ca_cert_path'])
    new_config = get_dex_auth_token(config['management_api_address'],
                                    config['management_api_port'],
                                    config['refresh_token'], ca_cert_path)
    new_config.update({
        'management_api_address':
        config['management_api_address'],
        'management_api_port':
        config['management_api_port']
    })
    save_to_file(config_file_path, new_config)
Beispiel #3
0
def main():
    global code
    args = parse_args()
    config_file_path = getenv('IMM_CONFIG_PATH',
                              join(expanduser("~"), '.immconfig'))
    auth_url = get_dex_auth_url(address=args.address,
                                port=args.port,
                                ca_cert_path=args.ca_cert,
                                proxy_host=args.proxy_host,
                                proxy_port=args.proxy_port,
                                insecure=args.insecure,
                                offline=args.offline)
    auth_url_with_refresh_token = enable_getting_refresh_token(auth_url)
    auth_url_unparsed = urlparse(auth_url)
    queries = parse_qs(auth_url_unparsed.query)
    redirect_port = urlparse(queries['redirect_uri'][0]).port

    if args.offline:
        print("Go to the following link in your browser:\n")
        print(auth_url_with_refresh_token)
        code = input("Enter verification code: ")
    else:
        run_server(redirect_port, auth_url_with_refresh_token)

    print('Code received, waiting for token.')
    token = get_dex_auth_token(address=args.address,
                               port=args.port,
                               auth_dict={'code': code},
                               ca_cert_path=args.ca_cert,
                               proxy_host=args.proxy_host,
                               proxy_port=args.proxy_port,
                               insecure=args.insecure,
                               offline=args.offline)
    token.update({
        'management_api_address': args.address,
        'management_api_port': args.port,
        'ca_cert_path': args.ca_cert
    })
    if args.proxy_host:
        token.update({
            'proxy_host': args.proxy_host,
            'proxy_port': args.proxy_port
        })
    save_to_file(config_file_path, token)
    print("Your token and refresh token are available in file: {}".format(
        config_file_path))
def main():
    args = parse_args()
    config_file_path = getenv('IMM_CONFIG_PATH',
                              join(expanduser("~"), '.immconfig'))
    config = read_config(config_file_path)
    ca_cert_path = check_cert(config['ca_cert_path'])
    proxy_host = config.get('proxy_host', None)
    proxy_port = config.get('proxy_port', None)
    new_token = get_dex_auth_token(
        address=config['management_api_address'],
        port=config['management_api_port'],
        auth_dict={'refresh_token': config['refresh_token']},
        ca_cert_path=ca_cert_path,
        proxy_host=proxy_host,
        proxy_port=proxy_port,
        insecure=args.insecure,
        offline=True)

    config.update(new_token)
    save_to_file(config_file_path, config)