Skip to content

Commit

Permalink
Added some line breaks to keep README.md text lines nice and short.
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-adams committed Mar 15, 2015
1 parent 57c2201 commit 7f7e96a
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ You can still get the payload by setting the `verify` argument to `False`.
jwt.decode('someJWTstring', verify=False)
```

The `decode()` function can raise other exceptions, e.g. for invalid issuer or audience (see below). All exceptions that signify that the token is invalid extend from the base `InvalidTokenError` exception class, so applications can use this approach to catch any issues relating to invalid tokens:
The `decode()` function can raise other exceptions, e.g. for invalid issuer or
audience (see below). All exceptions that signify that the token is invalid
extend from the base `InvalidTokenError` exception class, so applications can
use this approach to catch any issues relating to invalid tokens:

```python
try:
Expand Down Expand Up @@ -88,7 +91,8 @@ jwt.encode({'some': 'payload'}, 'secret', 'HS512')

Usage of RSA (RS\*) and EC (EC\*) algorithms require a basic understanding
of how public-key cryptography is used with regards to digital signatures.
If you are unfamiliar, you may want to read [this article](http://en.wikipedia.org/wiki/Public-key_cryptography).
If you are unfamiliar, you may want to read
[this article](http://en.wikipedia.org/wiki/Public-key_cryptography).

When using the RSASSA-PKCS1-v1_5 algorithms, the `key` argument in both
`jwt.encode()` and `jwt.decode()` (`"secret"` in the examples) is expected to
Expand All @@ -101,8 +105,8 @@ be an Elliptic Curve public or private key in PEM format. The type of key

## Support of registered claim names

JSON Web Token defines some registered claim names and defines how they should be
used. PyJWT supports these registered claim names:
JSON Web Token defines some registered claim names and defines how they should
be used. PyJWT supports these registered claim names:

- "exp" (Expiration Time) Claim
- "nbf" (Not Before Time) Claim
Expand Down Expand Up @@ -146,7 +150,8 @@ Expiration time will be compared to the current UTC time (as given by
`timegm(datetime.utcnow().utctimetuple())`), so be sure to use a UTC timestamp
or datetime in encoding.

You can turn off expiration time verification with the `verify_expiration` argument.
You can turn off expiration time verification with the `verify_expiration`
argument.

PyJWT also supports the leeway part of the expiration time definition, which
means you can validate a expiration time which is in the past but not very far.
Expand All @@ -170,7 +175,8 @@ time.sleep(32)
jwt.decode(jwt_payload, 'secret', leeway=10)
```

Instead of specifying the leeway as a number of seconds, a `datetime.timedelta` instance can be used. The last line in the example above is equivalent to:
Instead of specifying the leeway as a number of seconds, a `datetime.timedelta`
instance can be used. The last line in the example above is equivalent to:

```python
jwt.decode(jwt_payload, 'secret', leeway=datetime.timedelta(seconds=10))
Expand Down

0 comments on commit 7f7e96a

Please sign in to comment.