{"action":"opened","issue":{"url":"https://api.github.com/repos/duosecurity/duo_python/issues/8","labels_url":"https://api.github.com/repos/duosecurity/duo_python/issues/8/labels{/name}","comments_url":"https://api.github.com/repos/duosecurity/duo_python/issues/8/comments","events_url":"https://api.github.com/repos/duosecurity/duo_python/issues/8/events","html_url":"https://github.com/duosecurity/duo_python/issues/8","id":96301776,"number":8,"title":"Python library not compatible with HMAC, Base64 in Python 3.4","user":{"login":"cricalix","id":1478917,"avatar_url":"https://avatars.githubusercontent.com/u/1478917?v=3","gravatar_id":"","url":"https://api.github.com/users/cricalix","html_url":"https://github.com/cricalix","followers_url":"https://api.github.com/users/cricalix/followers","following_url":"https://api.github.com/users/cricalix/following{/other_user}","gists_url":"https://api.github.com/users/cricalix/gists{/gist_id}","starred_url":"https://api.github.com/users/cricalix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cricalix/subscriptions","organizations_url":"https://api.github.com/users/cricalix/orgs","repos_url":"https://api.github.com/users/cricalix/repos","events_url":"https://api.github.com/users/cricalix/events{/privacy}","received_events_url":"https://api.github.com/users/cricalix/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-07-21T12:12:12Z","updated_at":"2015-07-21T12:12:12Z","closed_at":null,"body":"When attempting to use the library in a Python 3.4 environment, the _sign_request() function will always return ERR_UNKNOWN. This comes down to the _sign_vals() function passing str objects to the underlying functions, instead of byte objects.\r\n\r\nUnderlying errors include:\r\nTypeError: 'str' does not support the buffer interface\r\nTypeError: Unicode-objects must be encoded before hashing\r\n\r\nRe-writing _sign_vals() to look like this:\r\ndef _sign_vals(key, vals, prefix, expire):\r\n    exp = str(int(time.time()) + expire)\r\n\r\n    val = '|'.join(vals + [ exp ])\r\n    b64 = base64.b64encode(str.encode(val))\r\n    cookie = '%s|%s' % (prefix, bytes.decode(b64))\r\n\r\n    sig = _hmac_sha1(str.encode(key), str.encode(cookie))\r\n    return '%s|%s' % (cookie, sig)\r\n\r\nworks just fine in Python 3.4, and in manual testing of the same functions in 2.7. As soon as I can work out how to put up "}}