• 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

86.36
/oauthlib/oauth1/rfc5849/errors.py
1
"""
2
oauthlib.oauth1.rfc5849.errors
3
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4

5
Error used both by OAuth 1 clients and provicers to represent the spec
6
defined error responses for all four core grant types.
7
"""
8
from oauthlib.common import add_params_to_uri, urlencode
6✔
9

10

11
class OAuth1Error(Exception):
6✔
12
    error = None
6✔
13
    description = ''
6✔
14

15
    def __init__(self, description=None, uri=None, status_code=400,
6✔
16
                 request=None):
17
        """
18
        description:    A human-readable ASCII [USASCII] text providing
19
                        additional information, used to assist the client
20
                        developer in understanding the error that occurred.
21
                        Values for the "error_description" parameter MUST NOT
22
                        include characters outside the set
23
                        x20-21 / x23-5B / x5D-7E.
24

25
        uri:    A URI identifying a human-readable web page with information
26
                about the error, used to provide the client developer with
27
                additional information about the error.  Values for the
28
                "error_uri" parameter MUST conform to the URI- Reference
29
                syntax, and thus MUST NOT include characters outside the set
30
                x21 / x23-5B / x5D-7E.
31

32
        state:  A CSRF protection value received from the client.
33

34
        request:  Oauthlib Request object
35
        """
36
        self.description = description or self.description
6✔
37
        message = '({}) {}'.format(self.error, self.description)
6✔
38
        if request:
6!
39
            message += ' ' + repr(request)
×
40
        super().__init__(message)
6✔
41

42
        self.uri = uri
6✔
43
        self.status_code = status_code
6✔
44

45
    def in_uri(self, uri):
6✔
46
        return add_params_to_uri(uri, self.twotuples)
×
47

48
    @property
6✔
49
    def twotuples(self):
6✔
50
        error = [('error', self.error)]
6✔
51
        if self.description:
6!
52
            error.append(('error_description', self.description))
6✔
53
        if self.uri:
6!
54
            error.append(('error_uri', self.uri))
×
55
        return error
6✔
56

57
    @property
6✔
58
    def urlencoded(self):
6✔
59
        return urlencode(self.twotuples)
6✔
60

61

62
class InsecureTransportError(OAuth1Error):
6✔
63
    error = 'insecure_transport_protocol'
6✔
64
    description = 'Only HTTPS connections are permitted.'
6✔
65

66

67
class InvalidSignatureMethodError(OAuth1Error):
6✔
68
    error = 'invalid_signature_method'
6✔
69

70

71
class InvalidRequestError(OAuth1Error):
6✔
72
    error = 'invalid_request'
6✔
73

74

75
class InvalidClientError(OAuth1Error):
6✔
76
    error = 'invalid_client'
6✔
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