Client authentication failed (e.g., unknown client, no client authentication included, or unsupported authentication method). The authorization server MAY return an HTTP 401 (Unauthorized) status code to indicate which HTTP authentication schemes are supported. If the client at
| 79 | |
| 80 | |
| 81 | class InvalidClientError(OAuth2Error): |
| 82 | """Client authentication failed (e.g., unknown client, no |
| 83 | client authentication included, or unsupported |
| 84 | authentication method). The authorization server MAY |
| 85 | return an HTTP 401 (Unauthorized) status code to indicate |
| 86 | which HTTP authentication schemes are supported. If the |
| 87 | client attempted to authenticate via the "Authorization" |
| 88 | request header field, the authorization server MUST |
| 89 | respond with an HTTP 401 (Unauthorized) status code and |
| 90 | include the "WWW-Authenticate" response header field |
| 91 | matching the authentication scheme used by the client. |
| 92 | |
| 93 | :rfc:`6749#section-5.2` |
| 94 | """ |
| 95 | |
| 96 | error = "invalid_client" |
| 97 | status_code = 400 |
| 98 | |
| 99 | def get_headers(self): |
| 100 | headers = super().get_headers() |
| 101 | if self.status_code == 401: |
| 102 | error_description = self.get_error_description() |
| 103 | # safe escape |
| 104 | error_description = error_description.replace('"', "|") |
| 105 | extras = [ |
| 106 | f'error="{self.error}"', |
| 107 | f'error_description="{error_description}"', |
| 108 | ] |
| 109 | headers.append(("WWW-Authenticate", "Basic " + ", ".join(extras))) |
| 110 | return headers |
| 111 | |
| 112 | |
| 113 | class InvalidGrantError(OAuth2Error): |
no outgoing calls
no test coverage detected