I'm following the Integrate with G-suite tutorial and apparently I'm having trouble with the private and public keys.
The tutorial asks to create a public key from the private key on the downloaded json file
I stored the private key on a file key.cem (converted all \n to actual carriage returns) and ran:
openssl pkey -in key.pem -pubout -out pubkey.pem
This gave me a public key. I converted the carriage returns to \n so the key would be single line
I made all relevant substitutions on the sample code. In particular, I'm substituting this for the keys
String SERVICE_ACCOUNT_PRIVATE_KEY = "-----BEGIN PRIVATE KEY-----\nMII ... KBU=\n-----END PRIVATE KEY-----\n";
String SERVICE_ACCOUNT_PUBLIC_KEY = "-----BEGIN PUBLIC KEY-----\nMIIBIj...QAB\n-----END PUBLIC KEY-----\n";
I set up a debug email account and inserted raw strings on the spreadsheet.
When I run the code in the Carriots Console I get the following two exceptions:
Message: Error en requestToken: Exception: Exception raised: java.security.InvalidKeyException: IOException: DerInputStream.getLength(): lengthTag=111, too big. Caused by: IOException: DerInputStream.getLength(): lengthTag=111, too big. sun.security.x509.X509Key.decode(X509Key.java:397)
Message: Business logic error: Exception: Exception raised: No such property: token for class: RestrictedScript
I think the problem has to do with the keys.
Am I copying them correctly? Shall I use the BEGIN END headers? Shall I use the \n characters or simply ignore them?
Many thanks for any help