I'm trying to load a .p12 file (Google certificate) from the filesystem in order to authenticate my application for Google Cloud Storage.
Credential credential = new GoogleCredential.Builder()
.setTransport(httpTransport)
.setJsonFactory(jsonFactory)
.setServiceAccountId("157264856793-sl14obknv58bi73m2co92oabrara9l8c@developer.gserviceaccount.com")
.setServiceAccountPrivateKeyFromP12File(resourceLoader.getResource("classpath:google-auth.p12").getFile())
.setServiceAccountScopes(scopes).build();
Unfortunately when trying to deploy the application (as a JAR onto Heroku) I get an error that I can't load a "file" from a JAR.
java.io.FileNotFoundException: class path resource [google-auth.p12] cannot be resolved to absolute file path because it does not reside in the file system: jar:file:/app/build/libs/Nitro.jar!/google-auth.p12
I've been advised to load the file as an inputstream
as opposed to a file, but the GoogleCredential doesn't seem to have an appropriate method, only:
setServiceAccountPrivateKeyFromP12File(File file)
method.
Advice apprecicated.