Hello,
I'm trying to use the JWT_Core dependency to create a JWT token so I can call Google Analytics API.
I created a Service Account in Google Cloud Platform, and generated a private key. The private key generated by Google is password-less.
I filled in the token payload, and for the TokenAsymmetricSigningCredentials, I specified:
However, when calling the CreateToken server action from JWT_Core, I get the error: "Unable to open private key. Validate if private key in PEM format and password is correct."
What can I do, considering that Google does not provide a password-less private key?
I also tried to use the CreateSignedAsymmetricTokenWithJsonWebKey server action of JWT module from the Forge (instead of JWT_Core), but was unable to set my private key in the field "JWKPlain" as Outsystems told me the content of the field was invalid.
Thanks for your help
Daniel
Hi Daniel,
I recently helped implement google auth using a service account to access a google API, if I remember correctly you should use the CreateSignedAsymmetricTokenWithPemKey action (JWT module) to create the token and when generating the keys google returns you a json file with the private key were each part of the private key is separated by \n, you cannot just copy that field, it should go from this:
"-----BEGIN PRIVATE KEY-----\nABCD\nABCD\n[...]\n-----END PRIVATE KEY-----\n"
To this:
"-----BEGIN PRIVATE KEY-----
ABCD
[...]
-----END PRIVATE KEY-----"
Feed the private key string like that to the action and don't forget to fill in the rest of the mandatory fields like KeyId, Issuer, IssuedAt, Audience and Claims.
Hope it helps.
Hi Rúben ,Did you really understand his problem? Daniel is said that he cannot create the JWT without the private key password .
Well, at time I was able to do it without the private key password but Daniel never responded so I guess we will never know.
@fran lok I was able to generate ACCESS TOKEN or IDENTITY TOKEN to use any Google Cloud API, having at disposal a JSON service account, following this approach