I was successfully able to create a stand-alone Java Application that creates Expiring Signed URL\'s to assets sitting in Google Cloud Storage. However, I have been unsucce
1/ Add the google api google-api-services-storage to your dependencies
2/ Then you need to create ServiceAccountAuthCredentials object from your service account ID and primary key :
serviceAccountAuthCredentials = AuthCredentials.createFor(resources.getString("authentication.p12.serviceAccountId"), pk);
3/ Finally you generate the signed URL from the ServiceAccountAuthCredentials object and the bucket and file name (no need to generate a String to sign) :
public String getSignedURL(String bucket, String fileName) throws IOException, GeneralSecurityException {
BlobId blobId = BlobId.of(bucket, fileName);
Blob blob = cloudStorageService.get(blobId);
URL signedURL = blob.signUrl(durationSignedURLAvailable, TimeUnit.MINUTES, com.google.cloud.storage.Storage.SignUrlOption.signWith(serviceAccountAuthCredentials));
return signedURL.toString();
}
This works fine for me.