JWTAssertionCredentials with a service account fails because asn1 is not enough data.

When I try to use SignedJwtAssertionCredentials () with a google service account, I get the following error on a single Windows 2008 server, but not on a Windows 7 machine locally.

Error: [('asn1 encoding routines', 'ASN1_D2I_READ_BIO', 'not enough data')]

I read the p12 key file as follows before passing it to SignedJwtAssertionCredentials ().

    with open(path_to_key_file, 'r') as f:
        private_key = f.read()
+4
source share
1 answer

The solution is to use binary mode when reading the file this way. Pay attention to 'b'

    with open(path_to_key_file, 'rb') as f:
        private_key = f.read()
+6
source

All Articles