i am using Rest API using netty library along with vertx event loop handle the multithreading, how to generate the access Token use it across all the threads in vertx event loop. Any idea how to handle this scenario.
i am using below code to generate the token and generating the token in every 45 mins.
public String generateAccessToken(byte[] serviceAccountKey) {
ByteArrayInputStream serviceAccountFile = null;
try {
serviceAccountFile = new ByteArrayInputStream(serviceAccountKey);
GoogleCredentials googleCredentials = GoogleCredentials.fromStream(serviceAccountFile)
.createScoped(Arrays.asList(SCOPES));
googleCredentials.refresh();
accessToken = googleCredentials.getAccessToken().getTokenValue();
} catch (Exception ex) {
LOGGER.E().errorLog(Logger.T, "Error while reading the json file", ex);
} finally {
PNSUtils.safeCloseInputStream(serviceAccountFile);
}
return accessToken;
}