3 ,[B2@sdZddlmZddlZddlmZmZGdddeZGdddeZ Gd d d eZ Gd d d eZ Gd ddeZ GdddeZ GdddeZGdddeZGdddeZGdddeZGdddeZGdddeZGdddeZGdd d eZGd!d"d"eZGd#d$d$eZGd%d&d&eZGd'd(d(eZGd)d*d*eZGd+d,d,eZGd-d.d.eZGd/d0d0eZGd1d2d2eZGd3d4d4eZGd5d6d6eZ Gd7d8d8eZ!Gd9d:d:eZ"Gd;d<dd>e#Z$Gd?d@d@e#Z%GdAdBdBe#Z&GdCdDdDe#Z'GdEdFdFe#Z(GdGdHdHe#Z)GdIdJdJe#Z*GdKdLdLe#Z+GdMdNdNe#Z,GdOdPdPeZ-GdQdRdReZ.dUdSdTZ/dS)Vz oauthlib.oauth2.rfc6749.errors ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Error used both by OAuth 2 clients and providers to represent the spec defined error responses for all four core grant types. )unicode_literalsN)add_params_to_uri urlencodecsVeZdZdZdZdZdfdd ZddZedd Z ed d Z ed d Z Z S) OAuth2ErrorNics|dk r||_d|j|jf}|r2|dt|7}tt|j|||_||_|rX||_|r|j |_ |j |_ |j |_ |j |_ |j |_ |j|_|s|j|_n$d|_ d|_ d|_ d|_ d|_ d|_dS)a description: A human-readable ASCII [USASCII] text providing additional information, used to assist the client developer in understanding the error that occurred. Values for the "error_description" parameter MUST NOT include characters outside the set x20-21 / x23-5B / x5D-7E. uri: A URI identifying a human-readable web page with information about the error, used to provide the client developer with additional information about the error. Values for the "error_uri" parameter MUST conform to the URI- Reference syntax, and thus MUST NOT include characters outside the set x21 / x23-5B / x5D-7E. state: A CSRF protection value received from the client. request: Oauthlib Request object Nz(%s) %s ) descriptionerrorreprsuperr__init__uristate status_codeZ redirect_uriZ client_idZscopesZ response_type response_modeZ grant_type)selfrr rrZrequestmessage) __class__/usr/lib/python3.6/errors.pyr s2 zOAuth2Error.__init__cCs|jdk}t||j|S)Nfragment)rr twotuples)rr rrrrin_uriIs zOAuth2Error.in_uricCsRd|jfg}|jr"|jd|jf|jr8|jd|jf|jrN|jd|jf|S)Nr error_description error_urir)r rappendr r)rr rrrrMs zOAuth2Error.twotuplescCs t|jS)N)rr)rrrr urlencodedXszOAuth2Error.urlencodedcCstjt|jS)N)jsondumpsdictr)rrrrr\szOAuth2Error.json)NNNNN) __name__ __module__ __qualname__r rrr rpropertyrrr __classcell__rr)rrrs3 rc@seZdZdZdS)TokenExpiredErrorZ token_expiredN)r r!r"r rrrrr%asr%c@seZdZdZdZdS)InsecureTransportErrorZinsecure_transportzOAuth 2 MUST utilize https.N)r r!r"r rrrrrr&esr&c@seZdZdZdZdS)MismatchingStateErrorZmismatching_statez6CSRF Warning! State not equal in request and response.N)r r!r"r rrrrrr'jsr'c@seZdZdZdS)MissingCodeErrorZ missing_codeN)r r!r"r rrrrr(osr(c@seZdZdZdS)MissingTokenErrorZ missing_tokenN)r r!r"r rrrrr)ssr)c@seZdZdZdS)MissingTokenTypeErrorZmissing_token_typeN)r r!r"r rrrrr*wsr*c@seZdZdZdS)FatalClientErrora Errors during authorization where user should not be redirected back. If the request fails due to a missing, invalid, or mismatching redirection URI, or if the client identifier is missing or invalid, the authorization server SHOULD inform the resource owner of the error and MUST NOT automatically redirect the user-agent to the invalid redirection URI. Instead the user should be informed of the error by the provider itself. N)r r!r"__doc__rrrrr+{s r+c@seZdZdZdZdS)InvalidRequestFatalErrorz For fatal errors, the request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed. invalid_requestN)r r!r"r,r rrrrr-sr-c@seZdZdZdS)InvalidRedirectURIErrorzInvalid redirect URI.N)r r!r"rrrrrr/sr/c@seZdZdZdS)MissingRedirectURIErrorzMissing redirect URI.N)r r!r"rrrrrr0sr0c@seZdZdZdS)MismatchingRedirectURIErrorzMismatching redirect URI.N)r r!r"rrrrrr1sr1c@seZdZdZdS)InvalidClientIdErrorz"Invalid client_id parameter value.N)r r!r"rrrrrr2sr2c@seZdZdZdS)MissingClientIdErrorzMissing client_id parameter.N)r r!r"rrrrrr3sr3c@seZdZdZdZdS)InvalidRequestErrorz The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed. r.N)r r!r"r,r rrrrr4sr4c@seZdZdZdS)MissingResponseTypeErrorz Missing response_type parameter.N)r r!r"rrrrrr5sr5c@seZdZdZdZdZdS)AccessDeniedErrorzH The resource owner or authorization server denied the request. Z access_deniediN)r r!r"r,r rrrrrr6sr6c@seZdZdZdZdS)UnsupportedResponseTypeErrorzj The authorization server does not support obtaining an authorization code using this method. Zunsupported_response_typeN)r r!r"r,r rrrrr7sr7c@seZdZdZdZdZdS)InvalidScopeErrorz@ The requested scope is invalid, unknown, or malformed. Z invalid_scopeiN)r r!r"r,r rrrrrr8sr8c@seZdZdZdZdS) ServerErrora  The authorization server encountered an unexpected condition that prevented it from fulfilling the request. (This error code is needed because a 500 Internal Server Error HTTP status code cannot be returned to the client via a HTTP redirect.) Z server_errorN)r r!r"r,r rrrrr9sr9c@seZdZdZdZdS)TemporarilyUnavailableErrora The authorization server is currently unable to handle the request due to a temporary overloading or maintenance of the server. (This error code is needed because a 503 Service Unavailable HTTP status code cannot be returned to the client via a HTTP redirect.) Ztemporarily_unavailableN)r r!r"r,r rrrrr:sr:c@seZdZdZdZdZdS)InvalidClientErroraG 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 attempted to authenticate via the "Authorization" request header field, the authorization server MUST respond with an HTTP 401 (Unauthorized) status code, and include the "WWW-Authenticate" response header field matching the authentication scheme used by the client. Zinvalid_clientiN)r r!r"r,r rrrrrr;s r;c@seZdZdZdZdZdS)InvalidGrantErrora The provided authorization grant (e.g. authorization code, resource owner credentials) or refresh token is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client. Z invalid_grantiN)r r!r"r,r rrrrrr<sr<c@seZdZdZdZdZdS)UnauthorizedClientErrorz^ The authenticated client is not authorized to use this authorization grant type. Zunauthorized_clientiN)r r!r"r,r rrrrrr=sr=c@seZdZdZdZdS)UnsupportedGrantTypeErrorzX The authorization grant type is not supported by the authorization server. Zunsupported_grant_typeN)r r!r"r,r rrrrr>sr>c@seZdZdZdZdS)UnsupportedTokenTypeErrorz The authorization server does not support the revocation of the presented token type. I.e. the client tried to revoke an access token on a server not supporting this feature. Zunsupported_token_typeN)r r!r"r,r rrrrr? sr?c@s eZdZdS)FatalOpenIDClientErrorN)r r!r"rrrrr@sr@c@s eZdZdS)OpenIDClientErrorN)r r!r"rrrrrAsrAc@seZdZdZdZdZdS)InteractionRequireda, The Authorization Server requires End-User interaction to proceed. This error MAY be returned when the prompt parameter value in the Authentication Request is none, but the Authentication Request cannot be completed without displaying a user interface for End-User interaction. Zinteraction_requirediN)r r!r"r,r rrrrrrBsrBc@seZdZdZdZdZdS) LoginRequireda' The Authorization Server requires End-User authentication. This error MAY be returned when the prompt parameter value in the Authentication Request is none, but the Authentication Request cannot be completed without displaying a user interface for End-User authentication. Zlogin_requirediN)r r!r"r,r rrrrrrC)srCc@seZdZdZdZdS)AccountSelectionRequireda The End-User is REQUIRED to select a session at the Authorization Server. The End-User MAY be authenticated at the Authorization Server with different associated accounts, but the End-User did not select a session. This error MAY be returned when the prompt parameter value in the Authentication Request is none, but the Authentication Request cannot be completed without displaying a user interface to prompt for a session to use. Zaccount_selection_requiredN)r r!r"r,r rrrrrD5s rDc@seZdZdZdZdZdS)ConsentRequireda The Authorization Server requires End-User consent. This error MAY be returned when the prompt parameter value in the Authentication Request is none, but the Authentication Request cannot be completed without displaying a user interface for End-User consent. Zconsent_requirediN)r r!r"r,r rrrrrrECsrEc@seZdZdZdZdZdS)InvalidRequestURIze The request_uri in the Authorization Request returns an error or contains invalid data. Zinvalid_request_urizWThe request_uri in the Authorization Request returns an error or contains invalid data.N)r r!r"r,r rrrrrrFOsrFc@seZdZdZdZdZdS)InvalidRequestObjectzC The request parameter contains an invalid Request Object. Zinvalid_request_objectz9The request parameter contains an invalid Request Object.N)r r!r"r,r rrrrrrGYsrGc@seZdZdZdZdZdS)RequestNotSupportedz? The OP does not support use of the request parameter. Zrequest_not_supportedz'The request parameter is not supported.N)r r!r"r,r rrrrrrHasrHc@seZdZdZdZdZdS)RequestURINotSupportedzC The OP does not support use of the request_uri parameter. Zrequest_uri_not_supportedz+The request_uri parameter is not supported.N)r r!r"r,r rrrrrrIisrIc@seZdZdZdZdZdS)RegistrationNotSupportedzD The OP does not support use of the registration parameter. Zregistration_not_supportedz,The registration parameter is not supported.N)r r!r"r,r rrrrrrJqsrJc@seZdZdZdZdZdZdS)InvalidTokenErrora The access token provided is expired, revoked, malformed, or invalid for other reasons. The resource SHOULD respond with the HTTP 401 (Unauthorized) status code. The client MAY request a new access token and retry the protected resource request. Z invalid_tokenizWThe access token provided is expired, revoked, malformed, or invalid for other reasons.N)r r!r"r,r rrrrrrrKysrKc@seZdZdZdZdZdZdS)InsufficientScopeErrora The request requires higher privileges than provided by the access token. The resource server SHOULD respond with the HTTP 403 (Forbidden) status code and MAY include the "scope" attribute with the scope necessary to access the protected resource. Zinsufficient_scopeizIThe request requires higher privileges than provided by the access token.N)r r!r"r,r rrrrrrrLsrLcCshddl}ddl}|jd|jd|jdd}x4|j|jt|jD]\}}|j|krD|f|qDWdS)Nrrrr)rr r)inspectsysgetZ getmembersmodulesr Zisclassr )r ZparamsrMrNkwargs_clsrrrraise_from_errors rT)N)0r,Z __future__rrZoauthlib.commonrr Exceptionrr%r&r'r(r)r*r+r-r/r0r1r2r3r4r5r6r7r8r9r:r;r<r=r>r?r@rArBrCrDrErFrGrHrIrJrKrLrTrrrrsV Q