I'm trying to make my function based rest framework views which use the @api_view
decorator with the Django OAuth Rest Framework Toolkit, where I'm using TokenHasScope
as the permission_class. However, this needs a mandatory attribute called required_scopes
but I'm not sure how I can get this specified in a function based views?
Asked
Active
Viewed 320 times
2

Rajiv Bharadwaj
- 83
- 1
- 4
2 Answers
0
Not exactly what you asked for, but an alternative to using Viewsets could be defining a view that subclass ScopedProtectedResourceView
and set the scopes with the required_scopes
attribute.

Duilio
- 876
- 1
- 10
- 15
0
You can create a view that subclasses TokenHasScope
then hardcode get_scopes
method to return the scopes you want. If the scopes change across different view, you can create a decorator which takes in a list of scopes and passes it on, then set your get_scopes
method to pick up the scopes from that decorator.

giwa_abdul
- 15
- 1
- 6