【问题标题】:Neo4J with Py2neo: Unauthorized error HTTPS带有 Py2neo 的 Neo4J:未经授权的错误 HTTPS
【发布时间】:2017-05-04 22:13:29
【问题描述】:

我有 Neo4JDocker 容器上运行,在该容器中我已将内部容器端口 7473 和 7687 映射到它们各自的主机端口 7473 和 7687,但 7474 已暴露但未映射。

关于网络的 Neo4J 服务器配置。

# Bolt connector dbms.connector.bolt.enabled=true
#dbms.connector.bolt.tls_level=OPTIONAL 
dbms.connector.bolt.listen_address=0.0.0.0:7687

# HTTP Connector. There must be exactly one HTTP connector. 
dbms.connector.http.enabled=true 
dbms.connector.http.listen_address=0.0.0.0:7474

# HTTPS Connector. There can be zero or one HTTPS connectors. 
dbms.connector.https.enabled=true 
dbms.connector.https.listen_address=0.0.0.0:7473

我可以通过浏览器登录 Neo4J 的 webclient 并更改默认密码。

关于 Python 代码,这里是我创建客户端的那一行。

self.client = py2neo.Graph(host    =ip_address,
                           username=username,
                           password=password,
                           secure  =use_secure,
                           bolt    =use_bolt)

只要我执行这样的查询。

node = Node("FooBar", foo="bar")
self.client.create(node)

我得到以下未经授权的异常。

py2neo.database.status.Unauthorized: https://localhost:7473/db/data/

知道为什么会发生这种情况吗?

【问题讨论】:

    标签: python database docker neo4j py2neo


    【解决方案1】:

    解决方案是调用库提供的单独身份验证方法,如下所示:

    auth_port = str(self._PORT_HTTPS if use_secure else self._PORT_HTTP)
    py2neo.authenticate(":".join([ip_address, auth_port]), username, password)
    

    我花了一段时间才明白这一点,因为起初我认为身份验证是在构造函数中自动完成的,然后我无法让身份验证方法运行,因为我使用的是螺栓端口。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多