From ef402f918959baac5d4ce5a9cc907e0596b8af13 Mon Sep 17 00:00:00 2001 From: Yao Tang Date: Tue, 23 Apr 2024 11:36:06 +0100 Subject: [PATCH] Add section to doc demo persistent token storage --- docs/intro.txt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/docs/intro.txt b/docs/intro.txt index c3e527f7..1bce40d3 100644 --- a/docs/intro.txt +++ b/docs/intro.txt @@ -183,6 +183,24 @@ For the Quantinuum ``Backend``, ``process_circuits`` returns a ``ResultHandle`` The ``logout()`` method clears stored JSON web tokens and the user will have to sign in again to access the Quantinuum API. +Persistent Authentication Token Storage +--------------------------------------- + +Following a successful login, the refresh token and the ID token, which are required for making further requests, will be saved. +This means you won't need to re-enter your credentials until these tokens expire. By default, these tokens are only stored in memory and will be removed once the Python session ends or if you manually log out. + +For more persistent storage, consider using the ``QuantinuumConfigCredentialStorage``. This storage option saves your username and the authentication tokens to the ``pytket`` configuration file, ensuring they persist beyond the current session. +:: + + from pytket.extensions.quantinuum.backends.api_wrappers import QuantinuumAPI + from pytket.extensions.quantinuum.backends.credential_storage import ( + QuantinuumConfigCredentialStorage, + ) + backend = QuantinuumBackend( + device_name=machine, + api_handler=QuantinuumAPI(token_store=QuantinuumConfigCredentialStorage()), + ) + Partial Results Retrieval -------------------------