• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

oauthlib / oauthlib / 16526823736

25 Jul 2025 04:27PM UTC coverage: 92.909% (+0.06%) from 92.846%
16526823736

Pull #918

github

web-flow
Merge e3c8b4631 into 0667a391a
Pull Request #918: Add pre-commit to run linters, formatters, etc. on code changes

1018 of 1128 branches covered (90.25%)

Branch coverage included in aggregate %.

3109 of 3314 relevant lines covered (93.81%)

5.61 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/oauthlib/openid/connect/core/exceptions.py
1
"""
2
oauthlib.oauth2.rfc6749.errors
3
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4

5
Error used both by OAuth 2 clients and providers to represent the spec
6
defined error responses for all four core grant types.
7
"""
8
import inspect
×
9
import sys
×
10

11
from oauthlib.oauth2.rfc6749.errors import FatalClientError, OAuth2Error
×
12

13

14
class FatalOpenIDClientError(FatalClientError):
×
15
    pass
×
16

17

18
class OpenIDClientError(OAuth2Error):
×
19
    pass
×
20

21

22
class InteractionRequired(OpenIDClientError):
×
23
    """
24
    The Authorization Server requires End-User interaction to proceed.
25

26
    This error MAY be returned when the prompt parameter value in the
27
    Authentication Request is none, but the Authentication Request cannot be
28
    completed without displaying a user interface for End-User interaction.
29
    """
30
    error = 'interaction_required'
×
31
    status_code = 401
×
32

33

34
class LoginRequired(OpenIDClientError):
×
35
    """
36
    The Authorization Server requires End-User authentication.
37

38
    This error MAY be returned when the prompt parameter value in the
39
    Authentication Request is none, but the Authentication Request cannot be
40
    completed without displaying a user interface for End-User authentication.
41
    """
42
    error = 'login_required'
×
43
    status_code = 401
×
44

45

46
class AccountSelectionRequired(OpenIDClientError):
×
47
    """
48
    The End-User is REQUIRED to select a session at the Authorization Server.
49

50
    The End-User MAY be authenticated at the Authorization Server with
51
    different associated accounts, but the End-User did not select a session.
52
    This error MAY be returned when the prompt parameter value in the
53
    Authentication Request is none, but the Authentication Request cannot be
54
    completed without displaying a user interface to prompt for a session to
55
    use.
56
    """
57
    error = 'account_selection_required'
×
58

59

60
class ConsentRequired(OpenIDClientError):
×
61
    """
62
    The Authorization Server requires End-User consent.
63

64
    This error MAY be returned when the prompt parameter value in the
65
    Authentication Request is none, but the Authentication Request cannot be
66
    completed without displaying a user interface for End-User consent.
67
    """
68
    error = 'consent_required'
×
69
    status_code = 401
×
70

71

72
class InvalidRequestURI(OpenIDClientError):
×
73
    """
74
    The request_uri in the Authorization Request returns an error or
75
    contains invalid data.
76
    """
77
    error = 'invalid_request_uri'
×
78
    description = ('The request_uri in the Authorization Request returns an '
×
79
                  'error or contains invalid data.')
80

81

82
class InvalidRequestObject(OpenIDClientError):
×
83
    """
84
    The request parameter contains an invalid Request Object.
85
    """
86
    error = 'invalid_request_object'
×
87
    description = 'The request parameter contains an invalid Request Object.'
×
88

89

90
class RequestNotSupported(OpenIDClientError):
×
91
    """
92
    The OP does not support use of the request parameter.
93
    """
94
    error = 'request_not_supported'
×
95
    description = 'The request parameter is not supported.'
×
96

97

98
class RequestURINotSupported(OpenIDClientError):
×
99
    """
100
    The OP does not support use of the request_uri parameter.
101
    """
102
    error = 'request_uri_not_supported'
×
103
    description = 'The request_uri parameter is not supported.'
×
104

105

106
class RegistrationNotSupported(OpenIDClientError):
×
107
    """
108
    The OP does not support use of the registration parameter.
109
    """
110
    error = 'registration_not_supported'
×
111
    description = 'The registration parameter is not supported.'
×
112

113

114
class InvalidTokenError(OAuth2Error):
×
115
    """
116
    The access token provided is expired, revoked, malformed, or
117
    invalid for other reasons.  The resource SHOULD respond with
118
    the HTTP 401 (Unauthorized) status code.  The client MAY
119
    request a new access token and retry the protected resource
120
    request.
121
    """
122
    error = 'invalid_token'
×
123
    status_code = 401
×
124
    description = ("The access token provided is expired, revoked, malformed, "
×
125
                   "or invalid for other reasons.")
126

127

128
class InsufficientScopeError(OAuth2Error):
×
129
    """
130
    The request requires higher privileges than provided by the
131
    access token.  The resource server SHOULD respond with the HTTP
132
    403 (Forbidden) status code and MAY include the "scope"
133
    attribute with the scope necessary to access the protected
134
    resource.
135
    """
136
    error = 'insufficient_scope'
×
137
    status_code = 403
×
138
    description = ("The request requires higher privileges than provided by "
×
139
                   "the access token.")
140

141

142
def raise_from_error(error, params=None):
×
143
    kwargs = {
×
144
        'description': params.get('error_description'),
145
        'uri': params.get('error_uri'),
146
        'state': params.get('state')
147
    }
148
    for _, cls in inspect.getmembers(sys.modules[__name__], inspect.isclass):
×
149
        if cls.error == error:
×
150
            raise cls(**kwargs)
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc