Skip to content

Commit

Permalink
Merge f01df86 into b17c087
Browse files Browse the repository at this point in the history
  • Loading branch information
CorreyL committed Apr 24, 2020
2 parents b17c087 + f01df86 commit a3205d2
Showing 1 changed file with 35 additions and 8 deletions.
43 changes: 35 additions & 8 deletions docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Usage Examples
==============

Encoding & Decoding Tokens with HS256
---------------------------------
--------------------------------------

.. code-block:: python
Expand All @@ -14,7 +14,7 @@ Encoding & Decoding Tokens with HS256
{'some': 'payload'}
Encoding & Decoding Tokens with RS256 (RSA)
---------------------------------
-------------------------------------------

.. code-block:: python
Expand Down Expand Up @@ -183,12 +183,23 @@ Audience Claim (aud)
identify itself with a value in the audience claim. If the principal
processing the claim does not identify itself with a value in the
"aud" claim when this claim is present, then the JWT MUST be
rejected. In the general case, the "aud" value is an array of case-
sensitive strings, each containing a StringOrURI value. In the
special case when the JWT has one audience, the "aud" value MAY be a
single case-sensitive string containing a StringOrURI value. The
interpretation of audience values is generally application specific.
Use of this claim is OPTIONAL.
rejected.

In the general case, the "aud" value is an array of case-
sensitive strings, each containing a StringOrURI value.

.. code-block:: python
payload = {
'some': 'payload',
'aud': ['urn:foo', 'urn:bar']
}
token = jwt.encode(payload, 'secret')
decoded = jwt.decode(token, 'secret', audience='urn:foo', algorithms=['HS256'])
In the special case when the JWT has one audience, the "aud" value MAY be
a single case-sensitive string containing a StringOrURI value.

.. code-block:: python
Expand All @@ -200,6 +211,22 @@ Audience Claim (aud)
token = jwt.encode(payload, 'secret')
decoded = jwt.decode(token, 'secret', audience='urn:foo', algorithms=['HS256'])
If multiple audiences are accepted, the ``audience`` parameter for
``jwt.decode`` can also be an iterable

.. code-block:: python
payload = {
'some': 'payload',
'aud': 'urn:foo'
}
token = jwt.encode(payload, 'secret')
decoded = jwt.decode(token, 'secret', audience=['urn:foo', 'urn:bar'], algorithms=['HS256'])
The interpretation of audience values is generally application specific.
Use of this claim is OPTIONAL.

If the audience claim is incorrect, `jwt.InvalidAudienceError` will be raised.

Issued At Claim (iat)
Expand Down

0 comments on commit a3205d2

Please sign in to comment.