> +
> +   private GoogleComputeEngineCredentialSupplierFromJson(String jsonString){
> +      creds = parseJsonKeyString(jsonString);
> +   }
> +
> +   /**
> +    * Function for parsing JSON Key file downloaded from GCP developers 
> console.
> +    *
> +    * @param pathToJsonFile.
> +    * @return Credentials object with Credentials.identity and 
> Credentials.credential correctly set.
> +    */
> +   public static Credentials parseJsonKeyString(String jsonString) {
> +      // Parse JsonFile to extract Service Account and PrivateKey.
> +      final JsonObject json = new 
> JsonParser().parse(jsonString).getAsJsonObject();
> +      String client_email = 
> json.get("client_email").toString().replace("\"", "");
> +      String private_key = 
> StringEscapeUtils.unescapeJava(json.get("private_key").toString().replace("\"",
>  ""));

Without the unescapeJava it was was incorrectly treating \n as two separate 
characters instead of newlines. The client email doesn't have any \n characters 
so it is a non-issue.

I found a simpler way to fix the newline character.
`json.get("private_key").toString().replace("\"", "").replace("\\n", "\n");`

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/124/files#r23739041

Reply via email to