Mixins for Class Based Views¶
-
class
oauth2_provider.views.mixins.OAuthLibMixin¶ This mixin decouples Django OAuth Toolkit from OAuthLib.
Users can configure the Server, Validator and OAuthlibCore classes used by this mixin by setting the following class variables:
- server_class
- validator_class
- oauthlib_backend_class
A wrapper method that calls create_authorization_response on server_class instance.
Parameters: - request – The current django.http.HttpRequest object
- scopes – A space-separated string of provided scopes
- credentials – Authorization credentials dictionary containing client_id, state, redirect_uri, response_type
- allow – True if the user authorize the client, otherwise False
-
create_revocation_response(request)¶ A wrapper method that calls create_revocation_response on the server_class instance.
Parameters: request – The current django.http.HttpRequest object
-
create_token_response(request)¶ A wrapper method that calls create_token_response on server_class instance.
Parameters: request – The current django.http.HttpRequest object
-
error_response(error, **kwargs)¶ Return an error to be displayed to the resource owner if anything goes awry.
Parameters: error – OAuthToolkitError
-
classmethod
get_oauthlib_backend_class()¶ Return the OAuthLibCore implementation class to use
-
classmethod
get_oauthlib_core()¶ Cache and return OAuthlibCore instance so it will be created only on first request
-
get_scopes()¶ This should return the list of scopes required to access the resources. By default it returns an empty list.
-
classmethod
get_server()¶ Return an instance of server_class initialized with a validator_class object
-
classmethod
get_server_class()¶ Return the OAuthlib server class to use
-
classmethod
get_validator_class()¶ Return the RequestValidator implementation class to use
A wrapper method that calls validate_authorization_request on server_class instance.
Parameters: request – The current django.http.HttpRequest object
-
verify_request(request)¶ A wrapper method that calls verify_request on server_class instance.
Parameters: request – The current django.http.HttpRequest object
-
class
oauth2_provider.views.mixins.ProtectedResourceMixin¶ Helper mixin that implements OAuth2 protection on request dispatch, specially useful for Django Generic Views