Skip to content
This repository was archived by the owner on May 26, 2020. It is now read-only.

Commit 462d6fc

Browse files
committed
Update Usage docs.
1 parent 625d45d commit 462d6fc

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

docs/index.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,13 @@ $ curl -H "Authorization: JWT <your_token>" http://localhost:8000/protected-url/
101101
## Refresh Token
102102
If `JWT_ALLOW_REFRESH` is True, issued tokens can be "refreshed" to obtain a new brand token with renewed expiration time. Add a URL pattern like this:
103103
```python
104-
url(r'^api-token-refresh/', 'rest_framework_jwt.views.refresh_jwt_token'),
104+
from rest_framework_jwt.views import refresh_jwt_token
105+
# ...
106+
107+
urlpatterns = [
108+
# ...
109+
url(r'^api-token-refresh/', refresh_jwt_token),
110+
]
105111
```
106112

107113
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}`.
@@ -120,7 +126,14 @@ In some microservice architectures, authentication is handled by a single servic
120126

121127
This setup is supported in this package using a verification endpoint. Add the following URL pattern:
122128
```python
123-
url(r'^api-token-verify/', 'rest_framework_jwt.views.verify_jwt_token'),
129+
from rest_framework_jwt.views import verify_jwt_token
130+
131+
#...
132+
133+
urlpatterns = [
134+
# ...
135+
url(r'^api-token-verify/', verify_jwt_token),
136+
]
124137
```
125138

126139
Passing a token to the verification endpoint will return a 200 response and the token if it is valid. Otherwise, it will return a 400 Bad Request as well as an error identifying why the token was invalid.

0 commit comments

Comments
 (0)