brandond / requests-negotiate-sspi

Windows SSPI-based Negotiate authentication support for Requests.
Apache License 2.0
131 stars 24 forks source link

TypeError: 'error' object is not subscriptable #19

Open kappa10j opened 4 years ago

kappa10j commented 4 years ago

When executing the following code:

"with requests.get(addr, auth=HttpNegotiateAuth(), timeout=30) as res:"

an exception is thrown at line 2 which isn't subscriptable so the library throws an exception at line 8. The issue arises when there is an authorization issue with our iis server. Can the library be fixed so I can get a proper response error message? What other info would you need from me?

thanks

try: --> error, auth = clientauth.authorize(sec_buffer) request.headers['Authorization'] = '{} {}'.format(scheme, base64.b64encode(auth[0].Buffer).decode('ASCII')) _logger.debug('Sending Response - error={} authenticated={}'.format(error, clientauth.authenticated)) except pywintypes.error as e: --> _logger.debug('Error calling {}: {}'.format(e[1], e[2]), exc_info=e) return response

vishwas-a-n commented 4 years ago

error in accessing/handling pywintypes.error object @ line #123 & #185

except pywintypes.error as e:
    _logger.debug('Error calling {}: {}'.format(e[1], e[2]), exc_info=e)
    return response

Below is the fix

except pywintypes.error as e:
    _logger.debug('Error calling {}: {}'.format(e.args[1], e.args[2]), exc_info=e)
    return response

kindly fix this.

kappa10j commented 4 years ago

thanks for the response. Is this something I should fix locally in the library or would it be updated in the pip package?

alex-ledovsky commented 2 years ago

Same thing..