DSS connection to GCS - Unable to read private key

Solved!
moisesmarrero
Level 3
DSS connection to GCS - Unable to read private key

hello, 

Wen configuring DSS connection to GCS the json file failed to be read. 

When introducing the key file (json file) generated for GCP:

first I received the error message where "type" field is missing, I added mannually "type":service-acount" and now it's complaining with:

Connection failed: Unable to extract private key from supplied JSON string., caused by: IOException: Error reading service account credential from stream, expecting 'client_id', 'client_email', 'private_key' and 'private_key_id'.

the entire field needs rework ? is there a similar situation when generating the json file from GCP? 

thanks in advance.


Operating system used: CentOS8

0 Kudos
1 Solution
moisesmarrero
Level 3
Author

yes, the json file was being exported corrupted in my browser. 

I took reference of the file structure frol here: https://github.com/googleapis/google-auth-library-java/blob/main/oauth2_http/java/com/google/auth/oa...

String fileType = (String) fileContents.get("type");
if (fileType == null) {
throw new IOException("Error reading credentials from stream, 'type' field not specified.");
}
if (USER_FILE_TYPE.equals(fileType)) {
return UserCredentials.fromJson(fileContents, transportFactory);
}
if (SERVICE_ACCOUNT_FILE_TYPE.equals(fileType)) {
return ServiceAccountCredentials.fromJson(fileContents, transportFactory);
}
if (GDCH_SERVICE_ACCOUNT_FILE_TYPE.equals(fileType)) {
return GdchCredentials.fromJson(fileContents);
}
if (ExternalAccountCredentials.EXTERNAL_ACCOUNT_FILE_TYPE.equals(fileType)) {
return ExternalAccountCredentials.fromJson(fileContents, transportFactory);
}

 

so I recreate the file and maje sure the file was indicating all the fileds. add it again in the system and this time it take it without problem. 

 

View solution in original post

4 Replies
Turribeach

Can you please post the contents of your GCP JSON file? (Replace the secret parts with xxx). 

0 Kudos
moisesmarrero
Level 3
Author

Hi! It's already solved, thanks very much

0 Kudos

Do you mind please sharing what was the problem and the solution so others can benefit from your post? Thanks

0 Kudos
moisesmarrero
Level 3
Author

yes, the json file was being exported corrupted in my browser. 

I took reference of the file structure frol here: https://github.com/googleapis/google-auth-library-java/blob/main/oauth2_http/java/com/google/auth/oa...

String fileType = (String) fileContents.get("type");
if (fileType == null) {
throw new IOException("Error reading credentials from stream, 'type' field not specified.");
}
if (USER_FILE_TYPE.equals(fileType)) {
return UserCredentials.fromJson(fileContents, transportFactory);
}
if (SERVICE_ACCOUNT_FILE_TYPE.equals(fileType)) {
return ServiceAccountCredentials.fromJson(fileContents, transportFactory);
}
if (GDCH_SERVICE_ACCOUNT_FILE_TYPE.equals(fileType)) {
return GdchCredentials.fromJson(fileContents);
}
if (ExternalAccountCredentials.EXTERNAL_ACCOUNT_FILE_TYPE.equals(fileType)) {
return ExternalAccountCredentials.fromJson(fileContents, transportFactory);
}

 

so I recreate the file and maje sure the file was indicating all the fileds. add it again in the system and this time it take it without problem.