Skip to content

[Q] ServiceAccount credentials from JSON and private_key_id field in it #5220

@spnshah

Description

@spnshah

Hello,

We are currently using google-cloud-cpp version v0.20.x for our integration with Google storage.

It was noticed that when trying to establish a service account credentials through JSON contents, private_id field is made mandatory to establish credentials, but we can pass dummy contents to it and it is able to connect to the service. The JSON is having all other fields correct except the private_id field.

json credJson;
credJson["client_email"] = <client_email>;            // Valid value in RHS.
credJson["private_key_id"] = "some dummy string";   // Invalid value in RHS.
credJson["private_key"] = <private_keyValue>;         // Valid value in RHS.
credJson["client_x509_cert_url"] = <x509>;            // Valid value in RHS.
credJson["type"] = "service_account";                 // Valid value in RHS.
credJson["auth_uri"] = "https://accounts.google.com/o/oauth2/auth";
credJson["token_uri"] = "https://oauth2.googleapis.com/token";
credJson["auth_provider_x509_cert_url"] = "https://www.googleapis.com/oauth2/v1/certs";

std::string authStr = credJson.dump();
// Convert authStr to char* secret.
auto creds = oauth2::CreateServiceAccountCredentialsFromJsonContents(secret);

Let me know if I am missing something here in the implementation or if I have understood it incorrect but the overall concern is, with the way I am constructing object which carries the details to establish authentication, I am able to read objects (possibly other operation would be successful too) by having a dummy private_key_id.

Thanks,
Supen

Metadata

Metadata

Assignees

Labels

type: questionRequest for information or clarification. Not an issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions