-
Notifications
You must be signed in to change notification settings - Fork 809
Description
As a newbie to Django/Rest_framework/oauth-toolkit, I climbed the tutorial/quickstart ladder.
Then I got stuck.
The 'snippet' example for the rest_framework was the basis for what I wanted to do, using the ListAPIView
Using the example in the oauth_toolkit - (a literal hello world using the ProtectedResourceView), I thrashed around trying to mix the ProtectedResourceView in with the ListAPIView and spent a lot of time in the code of the three packages before I realized I missed one paragraph in the rest_framework docs and realized it was really, really simple...
from oauth2_provider.contrib.rest_framework import TokenHasReadWriteScope
class SnippetsList(generics.ListCreateAPIView):
...
permission_classes = [TokenHasReadWriteScope]
Proposing that the existing oauth_toolkit tutorial just have an addition that documents how to build on that rest_framework tutorial, or even suggests doing that tutorial first, and then showing the minor addition.
Side note:
One of the downsides to using the ProtectedResourceView (and maybe I just don't understand the multiple inheritance to get it right) was that I was not able to use generateschema with it. When I tried to add in the GenericAPIView, never could quite get the stars to line up and have it work in all the cases.