@@ -107,10 +107,17 @@ Auth
107
107
108
108
To authenticate with Neo4j the authentication details are supplied at driver creation.
109
109
110
- The auth token is an object of the class :class: `neo4j.Auth ` containing the details.
110
+ The auth token is an object of the class :class: `neo4j.Auth ` containing static details or :class: ` neo4j.auth_management.AuthManager ` object .
111
111
112
112
.. autoclass :: neo4j.Auth
113
113
114
+ .. autoclass :: neo4j.auth_management.AuthManager
115
+ :members:
116
+
117
+ .. autoclass :: neo4j.auth_management.AuthManagers
118
+ :members:
119
+
120
+ .. autoclass :: neo4j.auth_management.ExpiringAuth
114
121
115
122
116
123
Example:
@@ -154,7 +161,8 @@ Closing a driver will immediately shut down all connections in the pool.
154
161
155
162
.. autoclass :: neo4j.Driver()
156
163
:members: session, query_bookmark_manager, encrypted, close,
157
- verify_connectivity, get_server_info
164
+ verify_connectivity, get_server_info, verify_authentication,
165
+ supports_session_auth, supports_multi_db
158
166
159
167
.. method :: execute_query(query, parameters_=None,routing_=neo4j.RoutingControl.WRITE, database_=None, impersonated_user_=None, bookmark_manager_=self.query_bookmark_manager, result_transformer_=Result.to_eager_result, **kwargs)
160
168
@@ -174,7 +182,7 @@ Closing a driver will immediately shut down all connections in the pool.
174
182
175
183
def execute_query(
176
184
query_, parameters_, routing_, database_, impersonated_user_,
177
- bookmark_manager_, result_transformer_, **kwargs
185
+ bookmark_manager_, auth_, result_transformer_, **kwargs
178
186
):
179
187
def work(tx):
180
188
result = tx.run(query_, parameters_, **kwargs)
@@ -184,6 +192,7 @@ Closing a driver will immediately shut down all connections in the pool.
184
192
database=database_,
185
193
impersonated_user=impersonated_user_,
186
194
bookmark_manager=bookmark_manager_,
195
+ auth=auth_,
187
196
) as session:
188
197
if routing_ == RoutingControl.WRITE:
189
198
return session.execute_write(work)
@@ -263,6 +272,20 @@ Closing a driver will immediately shut down all connections in the pool.
263
272
264
273
See also the Session config :ref: `impersonated-user-ref `.
265
274
:type impersonated_user_: typing.Optional[str]
275
+ :param auth_:
276
+ Authentication information to use for this query.
277
+
278
+ By default, the driver configuration is used.
279
+
280
+ **This is a preview ** (see :ref: `filter-warnings-ref `).
281
+ It might be changed without following the deprecation policy.
282
+ See also
283
+ https://github.com/neo4j/neo4j-python-driver/wiki/preview-features
284
+
285
+ See also the Session config :ref: `session-auth-ref `.
286
+ :type auth_: typing.Union[
287
+ typing.Tuple[typing.Any, typing.Any], neo4j.Auth, None
288
+ ]
266
289
:param result_transformer_:
267
290
A function that gets passed the :class: `neo4j.Result ` object
268
291
resulting from the query and converts it to a different type. The
@@ -273,7 +296,6 @@ Closing a driver will immediately shut down all connections in the pool.
273
296
The transformer function must **not ** return the
274
297
:class: `neo4j.Result ` itself.
275
298
276
-
277
299
.. warning ::
278
300
279
301
N.B. the driver might retry the underlying transaction so the
@@ -334,7 +356,7 @@ Closing a driver will immediately shut down all connections in the pool.
334
356
335
357
Defaults to the driver's :attr: `.query_bookmark_manager `.
336
358
337
- Pass :const : `None ` to disable causal consistency.
359
+ Pass :data : `None ` to disable causal consistency.
338
360
:type bookmark_manager_:
339
361
typing.Union[neo4j.BookmarkManager, neo4j.BookmarkManager,
340
362
None]
@@ -348,9 +370,18 @@ Closing a driver will immediately shut down all connections in the pool.
348
370
:returns: the result of the ``result_transformer ``
349
371
:rtype: T
350
372
373
+ **This is experimental ** (see :ref: `filter-warnings-ref `).
374
+ It might be changed or removed any time even without prior notice.
375
+
376
+ We are looking for feedback on this feature. Please let us know what
377
+ you think about it here:
378
+ https://github.com/neo4j/neo4j-python-driver/discussions/896
379
+
351
380
.. versionadded :: 5.5
352
381
353
- .. versionchanged :: 5.8 stabilized from experimental
382
+ .. versionchanged :: 5.8
383
+ * Added the ``auth_ `` parameter.
384
+ * Stabilized from experimental.
354
385
355
386
356
387
.. _driver-configuration-ref :
@@ -428,7 +459,7 @@ Specify whether TCP keep-alive should be enabled.
428
459
:Type: ``bool ``
429
460
:Default: ``True ``
430
461
431
- **This is experimental. ** (See :ref: `filter-warnings-ref `)
462
+ **This is experimental ** (see :ref: `filter-warnings-ref `).
432
463
It might be changed or removed any time even without prior notice.
433
464
434
465
@@ -779,6 +810,7 @@ Session
779
810
.. automethod :: execute_write
780
811
781
812
813
+
782
814
Query
783
815
=====
784
816
@@ -799,6 +831,7 @@ To construct a :class:`neo4j.Session` use the :meth:`neo4j.Driver.session` metho
799
831
+ :ref: `default-access-mode-ref `
800
832
+ :ref: `fetch-size-ref `
801
833
+ :ref: `bookmark-manager-ref `
834
+ + :ref: `session-auth-ref `
802
835
+ :ref: `session-notifications-min-severity-ref `
803
836
+ :ref: `session-notifications-disabled-categories-ref `
804
837
@@ -811,7 +844,7 @@ Optional :class:`neo4j.Bookmarks`. Use this to causally chain sessions.
811
844
See :meth: `Session.last_bookmarks ` or :meth: `AsyncSession.last_bookmarks ` for
812
845
more information.
813
846
814
- :Default: `` None ` `
847
+ :Default: :data: ` None `
815
848
816
849
.. deprecated :: 5.0
817
850
Alternatively, an iterable of strings can be passed. This usage is
@@ -993,6 +1026,29 @@ See :class:`.BookmarkManager` for more information.
993
1026
.. versionchanged :: 5.8 stabilized from experimental
994
1027
995
1028
1029
+ .. _session-auth-ref :
1030
+
1031
+ ``auth ``
1032
+ --------
1033
+ Optional :class: `neo4j.Auth ` or ``(user, password) ``-tuple. Use this overwrite the
1034
+ authentication information for the session.
1035
+ This requires the server to support re-authentication on the protocol level. You can
1036
+ check this by calling :meth: `.Driver.supports_session_auth ` / :meth: `.AsyncDriver.supports_session_auth `.
1037
+
1038
+ It is not possible to overwrite the authentication information for the session with no authentication,
1039
+ i.e., downgrade the authentication at session level.
1040
+ Instead, you should create a driver with no authentication and upgrade the authentication at session level as needed.
1041
+
1042
+ **This is a preview ** (see :ref: `filter-warnings-ref `).
1043
+ It might be changed without following the deprecation policy.
1044
+ See also https://github.com/neo4j/neo4j-python-driver/wiki/preview-features
1045
+
1046
+ :Type: :data: `None `, :class: `.Auth ` or ``(user, password) ``-tuple
1047
+ :Default: :data: `None ` - use the authentication information provided during driver creation.
1048
+
1049
+ .. versionadded :: 5.x
1050
+
1051
+
996
1052
.. _session-notifications-min-severity-ref :
997
1053
998
1054
``notifications_min_severity ``
@@ -1287,7 +1343,7 @@ Graph
1287
1343
1288
1344
.. automethod :: relationship_type
1289
1345
1290
- **This is experimental. ** (See :ref: `filter-warnings-ref `)
1346
+ **This is experimental ** (see :ref: `filter-warnings-ref `).
1291
1347
It might be changed or removed any time even without prior notice.
1292
1348
1293
1349
@@ -1745,6 +1801,8 @@ Server-side errors
1745
1801
1746
1802
* :class: `neo4j.exceptions.TokenExpired `
1747
1803
1804
+ * :class: `neo4j.exceptions.TokenExpiredRetryable `
1805
+
1748
1806
* :class: `neo4j.exceptions.Forbidden `
1749
1807
1750
1808
* :class: `neo4j.exceptions.DatabaseError `
@@ -1780,6 +1838,9 @@ Server-side errors
1780
1838
.. autoexception :: neo4j.exceptions.TokenExpired()
1781
1839
:show-inheritance:
1782
1840
1841
+ .. autoexception :: neo4j.exceptions.TokenExpiredRetryable()
1842
+ :show-inheritance:
1843
+
1783
1844
.. autoexception :: neo4j.exceptions.Forbidden()
1784
1845
:show-inheritance:
1785
1846
0 commit comments