anandsekar272 / google-api-java-client

Automatically exported from code.google.com/p/google-api-java-client
0 stars 0 forks source link

setServiceAccountPrivateKeyFromP12File(InputStream p12File) #857

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
For now, you can't use a p12 stored as a resource and it coul be very usefull 
if you can setServiceAccountPrivateKeyFromP12File from an InputStream (way that 
you can access to the ressource).

Here is the method that I use : 
    public Builder setServiceAccountPrivateKeyFromP12File(InputStream p12File)
            throws GeneralSecurityException, IOException {
          serviceAccountPrivateKey = SecurityUtils.loadPrivateKeyFromKeyStore(
              SecurityUtils.getPkcs12KeyStore(), p12File, "notasecret",
              "privatekey", "notasecret");
          return this;
        }

Original issue reported on code.google.com by sebastie...@progis.fr on 12 Feb 2014 at 7:28

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I found another way to use your P12 as a resource on StackOverflow (works on 
AppEngine):  http://stackoverflow.com/a/24945108/2611083.

This method gives you a "PrivateKey" object and then you just have to use it 
with "setServiceAccountPrivateKey(PrivateKey serviceAccountPrivateKey)".

Original comment by benoit.s...@gmail.com on 24 Feb 2015 at 9:24