As mentioned in FAQ (http://www.openldap.org/faq/data/cache/347.html)
base64.urlsafe_b64encode replaces "/" by _ and "+" by "-" so I replaced
it with .encode('base64').

Test uncommented.