We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Describe the bug Base64 encoding requires proper Python3 string handling
To Reproduce Steps to reproduce the behavior, e.g.:
stetl.inputs.HttpInput
Expected Behavior No error.
Screenshots or Logfiles This is a left-over from the Python2 to Python3 migration: need to use Unicode Strings in Python3. Many examples like https://stackoverflow.com/questions/53340627/typeerror-expected-bytes-like-object-not-str
Context (please complete one or more from the following information):
stetl.outputs.HttpOutput
If running with Docker:
Additional context Current version stetl.inputs.HttpInput.
def add_authorization(self, request): """ Add authorization from config data. Authorization scheme-specific. May be extended or overloaded for additional schemes. :param request: the HTTP Request :return: """ auth_creds = self.auth auth_type = auth_creds['type'] auth_val = None if auth_type == 'basic': # Basic auth: http://mozgovipc.blogspot.nl/2012/06/python-http-basic-authentication-with.html # base64 encode username and password # write the Authorization header like: 'Basic base64encode(username + ':' + password) auth_val = base64.encodestring('%s:%s' % (auth_creds['user'], auth_creds['password'])) auth_val = "Basic %s" % auth_val elif auth_type == 'token': # Bearer Type, see eg. https://tools.ietf.org/html/rfc6750 auth_val = "%s %s" % (auth_creds['keyword'], auth_creds['token']) request.add_header("Authorization", auth_val.replace('\n', ''))
must become something like:
def add_authorization(self, request): """ Add authorization from config data. Authorization scheme-specific. May be extended or overloaded for additional schemes. :param request: the HTTP Request :return: """ auth_creds = self.auth auth_type = auth_creds['type'] auth_val = None if auth_type == 'basic': # Basic auth: http://mozgovipc.blogspot.nl/2012/06/python-http-basic-authentication-with.html # base64 encode username and password # write the Authorization header like: 'Basic base64encode(username + ':' + password) auth_val = base64.encodebytes( '{}:{}'.format(auth_creds['user'], auth_creds['password']).encode()) auth_val = 'Basic {}'.format(auth_val.decode()) elif auth_type == 'token': # Bearer Type, see eg. https://tools.ietf.org/html/rfc6750 auth_val = "%s %s" % (auth_creds['keyword'], auth_creds['token']) request.add_header("Authorization", auth_val.replace('\n', ''))
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Describe the bug
Base64 encoding requires proper Python3 string handling
To Reproduce
Steps to reproduce the behavior, e.g.:
stetl.inputs.HttpInput
with Basic AuthExpected Behavior
No error.
Screenshots or Logfiles
This is a left-over from the Python2 to Python3 migration: need to use Unicode Strings in Python3.
Many examples like https://stackoverflow.com/questions/53340627/typeerror-expected-bytes-like-object-not-str
Context (please complete one or more from the following information):
stetl.inputs.HttpInput
andstetl.outputs.HttpOutput
(maybe more)If running with Docker:
Additional context
Current version
stetl.inputs.HttpInput
.must become something like:
The text was updated successfully, but these errors were encountered: