I may be missing something here, but this doesn't appear to support Python3 currently. In order to initialize the credentials, you are expected to pass in the private key file's contents as a string, so this would work for Python2:
with open(KEY_FILE) as f:
private_key = f.read()
oauth2credentials = oauth2client.client.SignedJwtAssertionCredentials(
SERVICE_ACCOUNT_EMAIL, private_key, SCOPE, sub=None)
Doing the same for Python3 would result in a UnicodeDecodeError, as it should be read in binary. Ideally, it would work as follows:
with open(KEY_FILE, 'rb') as f:
private_key = f.read()
oauth2credentials = oauth2client.client.SignedJwtAssertionCredentials(
SERVICE_ACCOUNT_EMAIL, private_key, SCOPE, sub=None)
However, while it will make it past the initialization step (it probably shouldn't), it will throw a TypeError later when you attempt to do a refresh because crypto.load_pkcs12(key, password) is expecting the key to be a string.
The easiest solution that comes to mind is to handle the private key differently depending on whether it is a str or bytes.
I may be missing something here, but this doesn't appear to support Python3 currently. In order to initialize the credentials, you are expected to pass in the private key file's contents as a string, so this would work for Python2:
Doing the same for Python3 would result in a UnicodeDecodeError, as it should be read in binary. Ideally, it would work as follows:
However, while it will make it past the initialization step (it probably shouldn't), it will throw a TypeError later when you attempt to do a refresh because crypto.load_pkcs12(key, password) is expecting the key to be a string.
The easiest solution that comes to mind is to handle the private key differently depending on whether it is a str or bytes.