Skip to content

Commit

Permalink
Refactor OAuth2Error
Browse files Browse the repository at this point in the history
  • Loading branch information
lepture committed Oct 18, 2017
1 parent e575cca commit c6b1137
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions oauthlib/oauth2/rfc6749/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ class OAuth2Error(Exception):
status_code = 400
description = ''

def __init__(self, description=None, uri=None, state=None, status_code=None,
request=None):
def __init__(self, description=None, uri=None, state=None,
status_code=None, request=None):
"""
description: A human-readable ASCII [USASCII] text providing
additional information, used to assist the client
Expand All @@ -39,8 +39,9 @@ def __init__(self, description=None, uri=None, state=None, status_code=None,
request: Oauthlib Request object
"""
self.response_mode = None
self.description = description or self.description
if description is not None:
self.description = description

message = '(%s) %s' % (self.error, self.description)
if request:
message += ' ' + repr(request)
Expand All @@ -61,10 +62,17 @@ def __init__(self, description=None, uri=None, state=None, status_code=None,
self.grant_type = request.grant_type
if not state:
self.state = request.state
else:
self.redirect_uri = None
self.client_id = None
self.scopes = None
self.response_type = None
self.response_mode = None
self.grant_type = None

def in_uri(self, uri):
return add_params_to_uri(uri, self.twotuples,
fragment=self.response_mode == "fragment")
fragment = self.response_mode == "fragment"
return add_params_to_uri(uri, self.twotuples, fragment)

@property
def twotuples(self):
Expand Down

0 comments on commit c6b1137

Please sign in to comment.