diff options
Diffstat (limited to 'oauthlib/oauth2/rfc6749/errors.py')
-rw-r--r-- | oauthlib/oauth2/rfc6749/errors.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/oauthlib/oauth2/rfc6749/errors.py b/oauthlib/oauth2/rfc6749/errors.py index 5a0cca2..8882ab2 100644 --- a/oauthlib/oauth2/rfc6749/errors.py +++ b/oauthlib/oauth2/rfc6749/errors.py @@ -313,6 +313,7 @@ class ConsentRequired(OAuth2Error): error = 'consent_required' status_code = 401 + class LoginRequired(OAuth2Error): """ The Authorization Server requires End-User authentication. @@ -325,6 +326,16 @@ class LoginRequired(OAuth2Error): status_code = 401 +class CustomOAuth2Error(OAuth2Error): + """ + This error is a placeholder for all custom errors not described by the RFC. + Some of the popular OAuth2 providers are using custom errors. + """ + def __init__(self, error, *args, **kwargs): + self.error = error + super().__init__(*args, **kwargs) + + def raise_from_error(error, params=None): import inspect import sys @@ -336,3 +347,4 @@ def raise_from_error(error, params=None): for _, cls in inspect.getmembers(sys.modules[__name__], inspect.isclass): if cls.error == error: raise cls(**kwargs) + raise CustomOAuth2Error(error=error, **kwargs) |