Skip to content

Commit 5cbd28c

Browse files
itsrifatdbaxa
authored andcommitted
Add an example on how to generate jwt using a data uri private key
1 parent e11df34 commit 5cbd28c

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

README.rst

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,20 @@ Each time you call ``generate_jwt`` this will find the latest active key file (e
4848
signer = atlassian_jwt_auth.create_signer_from_file_private_key_repository('issuer', '/opt/jwtprivatekeys')
4949
a_jwt = signer.generate_jwt('audience')
5050
51+
To create a JWT using a data uri
52+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
53+
54+
.. code:: python
55+
56+
import atlassian_jwt_auth
57+
from atlassian_jwt_auth.key import DataUriPrivateKeyRetriever
58+
59+
key_id, private_key_pem = DataUriPrivateKeyRetriever('Your base64 encoded data uri').load('issuer')
60+
signer = atlassian_jwt_auth.create_signer('issuer', 'issuer/key', private_key_pem)
61+
a_jwt = signer.generate_jwt('audience')
62+
63+
64+
5165
To make an authenticated HTTP request
5266
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5367

@@ -72,7 +86,7 @@ to authenticate ``aiohttp`` requests:
7286
.. code:: python
7387
7488
import aiohttp
75-
89+
7690
import atlassian_jwt_auth
7791
from atlassian_jwt_auth.contrib.aiohttp import JWTAuth
7892
@@ -115,7 +129,7 @@ To verify a JWT
115129
116130
For Python versions starting from ``Python 3.5`` ``atlassian_jwt_auth.contrib.aiohttp``
117131
provides drop-in replacements for the components that
118-
perform HTTP requests, so that they use ``aiohttp`` instead of ``requests``:
132+
perform HTTP requests, so that they use ``aiohttp`` instead of ``requests``:
119133

120134
.. code:: python
121135

0 commit comments

Comments
 (0)