Skip to content

Commit b6af819

Browse files
committed
added docs for TokenHasScope permission class. ref #182
1 parent 628f9e6 commit b6af819

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

docs/rest-framework/permissions.rst

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,30 @@ Permissions
44
Django OAuth Toolkit provides a few utility classes to use along with other permissions in Django REST Framework,
55
so you can easily add scoped-based permission checks to your API views.
66

7+
More details on how to add custom permissions to your API Endpoints can be found at the official
8+
`Django REST Framework documentation <http://www.django-rest-framework.org/api-guide/permissions/>`_
79

810

911
TokenHasScope
1012
-------------
1113

12-
TODO: add docs for TokenHasScope permission class with usage examples
14+
The `TokenHasScope` permission class will allow the access only when the current access token has been
15+
authorized for all the scopes listed in the `required_scopes` field of the view.
16+
17+
For example:
18+
19+
.. code-block:: python
20+
21+
class SongView(views.APIView):
22+
authentication_classes = [OAuth2Authentication]
23+
permission_classes = [TokenHasScope]
24+
required_scopes = ['music']
25+
26+
The `required_scopes` attribute is mandatory.
1327

1428

1529
TokenHasReadWriteScope
1630
----------------------
1731

1832
TODO: add docs for TokenHasReadWriteScope permission class with usage examples
33+

oauth2_provider/ext/rest_framework/permissions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,4 @@ def get_scopes(self, request, view):
5959
read_write_scope = oauth2_settings.WRITE_SCOPE
6060

6161
return required_scopes + [read_write_scope]
62+

0 commit comments

Comments
 (0)