summaryrefslogtreecommitdiff
path: root/oauthlib/oauth2/rfc6749
diff options
context:
space:
mode:
Diffstat (limited to 'oauthlib/oauth2/rfc6749')
-rw-r--r--oauthlib/oauth2/rfc6749/errors.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/oauthlib/oauth2/rfc6749/errors.py b/oauthlib/oauth2/rfc6749/errors.py
index 3f0bfc0..d17e08e 100644
--- a/oauthlib/oauth2/rfc6749/errors.py
+++ b/oauthlib/oauth2/rfc6749/errors.py
@@ -316,6 +316,7 @@ class ConsentRequired(OAuth2Error):
error = 'consent_required'
status_code = 401
+
class LoginRequired(OAuth2Error):
"""
The Authorization Server requires End-User authentication.
@@ -328,6 +329,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(CustomOAuth2Error, self).__init__(*args, **kwargs)
+
+
def raise_from_error(error, params=None):
import inspect
import sys
@@ -339,3 +350,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)