Skip to content

Commit f56a97d

Browse files
authored
Add example for token-based authorization
Thanks @bashallc
1 parent f0902bd commit f56a97d

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

docs/usage.rst

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,20 @@ To simplify usage for ``HTTPBasicAuth``, you may also directly provide a usernam
6060
)
6161
6262
63-
To interact with server requiring certificate-based authentication, you can provide the CA bundle and client certificate using the ``ca_bundle`` and ``cert`` arguments, respectively.
63+
To interact with servers supporting token-based authorization, you can provide the access token using the ``headers`` argument (the header will be included in every client request message).
64+
65+
.. code-block:: python
66+
67+
from dicomweb_client.api import DICOMwebClient
68+
69+
access_token = "mytoken"
70+
client = DICOMwebClient(
71+
url="https://mydicomwebserver.com",
72+
headers={"Authorization": "Bearer {}".format(access_token)}
73+
)
74+
75+
76+
To interact with servers requiring certificate-based authentication, you can provide the CA bundle and client certificate using the ``ca_bundle`` and ``cert`` arguments, respectively.
6477

6578
.. code-block:: python
6679

0 commit comments

Comments
 (0)