Skip to content
New issue

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

binascii.Error: Invalid base64-encoded string (+workaround) #27

Open
Zydox opened this issue Apr 10, 2021 · 1 comment
Open

binascii.Error: Invalid base64-encoded string (+workaround) #27

Zydox opened this issue Apr 10, 2021 · 1 comment

Comments

@Zydox
Copy link

Zydox commented Apr 10, 2021

Hello.

I'm using the HttpNegotiateAuth() function with requests to post a file to a kerberos SSO webserver and keept getting this error message in windows:
File "C:\Users\X.X\AppData\Roaming\Python\Python39\site-packages\requests_negotiate_sspi\requests_negotiate_sspi.py", line 149, in _retry_using_http_Negotiate_auth
tokenbuf.Buffer = base64.b64decode(final)
File "c:\Program Files\Python39\lib\base64.py", line 87, in b64decode
return binascii.a2b_base64(s)
binascii.Error: Invalid base64-encoded string: number of data characters (505) cannot be 1 more than a multiple of 4

I found that the final variable in the list:
tokenbuf.Buffer = base64.b64decode(final)
didn't contain a = character at the end, when I replaced the current like with this:
tokenbuf.Buffer = base64.b64decode(final + (b'=' if final[:-1] != '=' else b''))

After that, I didn't have any issues.

Best regards,
Zydox

@michael-o
Copy link
Contributor

Can you share the Base64 string?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants