Mercurial > hg > orthanc
diff OrthancServer/Resources/Samples/Python/Replicate.py @ 4625:844ec5ecb6ef
Fix "OrthancServer/Resources/Samples/Python/Replicate.py" for Python 3.x
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 19 Apr 2021 10:28:24 +0200 |
parents | d9473bd5ed43 |
children | 7053502fbf97 |
line wrap: on
line diff
--- a/OrthancServer/Resources/Samples/Python/Replicate.py Thu Apr 15 11:29:40 2021 +0200 +++ b/OrthancServer/Resources/Samples/Python/Replicate.py Mon Apr 19 10:28:24 2021 +0200 @@ -51,7 +51,12 @@ # Authentication (for some weird reason, this method does not # always work) # http://en.wikipedia.org/wiki/Basic_access_authentication - headers['authorization'] = 'Basic ' + base64.b64encode(username + ':' + password) + + # The ".encode()" and ".decode()" below fix the following issue: + # https://groups.google.com/g/orthanc-users/c/KZ_iYOet5IQ/m/AUQWiSiAAQAJ + credentials = (username + ':' + password) + credentials_base64 = base64.b64encode(credentials.encode("ascii")).decode("ascii") + headers['authorization'] = 'Basic ' + credentials_base64 return headers