@Dinesh_Sitaraman2 ,
If you invoke the service pub.file:getFile and give it the same path, does it work? The error indicates to me that the path is perhaps invalid or the user under which the IS is running does not have access to it. I understand, however, you said the permissions are set properly.
One thing you can try for now is to pass the JSON into your service as a string. In fact, in my current project we have several integrations with Google Cloud Pub/Sub and BigQuery. We store the service account key JSON file in a secrets manager. During the token generation, we fetch the JSON first and then create a ByteArrayInputStream from it.
Here’s the method responsible for generating the token:
private static final String getAccessToken(String clientId, String audience, long expireAfter, String expireAfterUnit) throws Exception {
long now = System.currentTimeMillis();
if(expireAfter == -1L) {
// If expireAfter was not provided, default to the currently maximum allowed value of 1 hour
expireAfter = 1;
expireAfterUnit = TimeUnit.HOUR;
}
else if(expireAfterUnit == null) {
expireAfterUnit = TimeUnit.DEFAULT;
}
String serviceAccountKey = getCredential(clientId); // This fetches the JSON as a string from our secrets manager
GoogleCredential credential = GoogleCredential
.fromStream(new ByteArrayInputStream(serviceAccountKey.getBytes()));
PrivateKey privateKey = credential.getServiceAccountPrivateKey();
String privateKeyId = credential.getServiceAccountPrivateKeyId();
String clientEmail = (new ObjectMapper()).readTree(serviceAccountKey).get("client_email").asText();
Algorithm algorithm = Algorithm.RSA256(null, (RSAPrivateKey) privateKey);
Builder tokenBuilder = JWT.create()
.withKeyId(privateKeyId)
.withIssuer(clientEmail)
.withSubject(clientEmail)
.withAudience(audience)
.withIssuedAt(new Date(now));
if(expireAfter > 0L) {
tokenBuilder = tokenBuilder.withExpiresAt(new Date(now + convertToMillis(expireAfter, expireAfterUnit)));
}
String accessToken = tokenBuilder.sign(algorithm);
return accessToken;
}
Hope this helps but let me know if you have any more questions.
Percio
#webMethods#Integration-Server-and-ESB#Java