Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to make ServiceAccountCredentials.fromJson() a public method? #592

Open
juturupavankumar opened this issue Mar 13, 2021 · 3 comments
Labels
type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@juturupavankumar
Copy link

Is it possible to make ServiceAccountCredentials.fromJson() a public method so that it is accessible outside the package?

At the moment, I am using ServiceAccountCredentials.fromPkcs8(). However, using ServiceAccountCredentials.fromJson() might simplify some code at my end (which fromJson method also have before it calls fromPkcs8).

@yoshi-automation yoshi-automation added the triage me I really want to be triaged. label Mar 13, 2021
@Neenu1995 Neenu1995 added the type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. label Mar 15, 2021
@yoshi-automation yoshi-automation removed the triage me I really want to be triaged. label Mar 15, 2021
@chingor13
Copy link
Contributor

chingor13 commented Mar 15, 2021

In general, we prefer developers interact with the GoogleCredentials class unless you know for sure you are providing ServiceAccountCredentials. If you have a JSON file, you can use GoogleCredentials.fromStream(InputStream) which can handle more than just ServiceAccountCredentials without failing.

If this is not good enough for your needs, can you add more details about your use case and need to create the ServiceAccountCredentials from a Map<String, Object>?

@juturupavankumar
Copy link
Author

Hi,

My use case is, my client application receives the content of JSON file from another test account service. So my client application uses that JSON content to fetch ServiceAccountCredentials.

So currently I am using ServiceAccountCredentials.fromPkcs8() to fetch the ServiceAccountCredentials

@noonian
Copy link

noonian commented Jul 9, 2021

Supporting the Map<String, Object> interface would make it easier to fetch credentials when the key info has already been parsed. For instance, if the key info was being stored in a database instead of as a json file on disk.

I am using this library from Clojure, where it is idiomatic to parse json into data and manipulate that rather than treating json as a stream of bytes.

If one has already parsed the json, the current options are to use ServiceAccountCredentials.fromPkcs8() which is tedious, or to serialize the map of data into json just so GoogleCredentials.fromStream(InputStream) can parse it again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

5 participants