You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 26, 2020. It is now read-only.
If `JWT_ALLOW_TOKEN_RENEWAL` is True, issued tokens can be "refreshed" to obtain a new brand token with renewed expiration time. Add a URL pattern like this:
Pass in an existing token to the refresh endpoint as follows: `{"token": EXISTING_TOKEN}`. Note that only non-expired tokens will work. The JSON response looks the same as the normal obtain token endpoint `{"token": NEW_TOKEN}`.
71
+
72
+
```bash
73
+
$ curl -X POST -H "Content-Type: application/json" -d '{"token":"<EXISTING_TOKEN>}' http://localhost:8000/api-token-refresh/
74
+
```
75
+
76
+
Refresh with tokens can be repeated (token1 -> token2 -> token3), but this chain of token stores the time that the original token (obtained with username/password credentials), as `orig_iat`. You can only keep refreshing tokens up to `JWT_TOKEN_RENEWAL_LIMIT`.
77
+
78
+
64
79
## Additional Settings
65
80
There are some additional settings that you can override similar to how you'd do it with Django REST framework itself. Here are all the available defaults.
This packages uses the JSON Web Token Python implementation, [PyJWT](https://github.com/progrium/pyjwt) and allows to modify some of it's available options.
@@ -126,8 +147,24 @@ Default is `True`.
126
147
127
148
Default is `0` seconds.
128
149
129
-
130
150
### JWT_EXPIRATION_DELTA
131
151
This is an instance of Python's `datetime.timedelta`. This will be added to `datetime.utcnow()` to set the expiration time.
132
152
133
153
Default is `datetime.timedelta(seconds=300)`(5 minutes).
154
+
155
+
### JWT_ALLOW_TOKEN_RENEWAL
156
+
Enable token renewal functionality. Token issued from `rest_framework_jwt.views.obtain_jwt_token` will have an `orig_iat` field. Default is `False`
157
+
158
+
### JWT_TOKEN_RENEWAL_LIMIT
159
+
Limit on token renewal, is a `datetime.timedelta` instance. This is how much time after the original token that future tokens can be refreshed from.
160
+
161
+
Default is `datetime.timedelta(days=7)` (7 days).
162
+
163
+
### JWT_PAYLOAD_HANDLER
164
+
Specify a custom function to generate the token payload
165
+
166
+
### JWT_PAYLOAD_GET_USER_ID_HANDLER
167
+
If you store `user_id` differently than the default payload handler does, implement this function to fetch `user_id` from the payload.
0 commit comments