From 85b1da8772956e8725b65f3824d7295319fc92a5 Mon Sep 17 00:00:00 2001 From: Charles Law Date: Tue, 5 Jun 2018 15:58:03 -0700 Subject: [PATCH] Allow a validate class to be passed into the OAuth2 Provider to be used instead of requiring an instance of a class --- flask_oauthlib/provider/oauth2.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/flask_oauthlib/provider/oauth2.py b/flask_oauthlib/provider/oauth2.py index e336ef53..d182f6ea 100644 --- a/flask_oauthlib/provider/oauth2.py +++ b/flask_oauthlib/provider/oauth2.py @@ -69,10 +69,11 @@ def user(): return jsonify(request.oauth.user) """ - def __init__(self, app=None): + def __init__(self, app=None, validator_class=None): self._before_request_funcs = [] self._after_request_funcs = [] self._invalid_response = None + self._validator_class = validator_class if app: self.init_app(app) @@ -155,7 +156,10 @@ def validate_client_id(self, client_id): if hasattr(self, '_usergetter'): usergetter = self._usergetter - validator = OAuth2RequestValidator( + validator_class = self._validator_class + if validator_class is None: + validator_class = OAuth2RequestValidator + validator = validator_class( clientgetter=self._clientgetter, tokengetter=self._tokengetter, grantgetter=self._grantgetter,