private Indy init(String accessToken) {
Indy indy = indyMap.get(accessToken);
if (indy == null) {
IndyClientAuthenticator authenticator = null;
if (accessToken != null) {
authenticator = new OAuth20BearerTokenAuthenticator(accessToken);
}
try {
SiteConfig siteConfig = new SiteConfigBuilder("indy", baseUrl)
.withRequestTimeoutSeconds(DEFAULT_REQUEST_TIMEOUT)
.withMaxConnections(IndyClientHttp.GLOBAL_MAX_CONNECTIONS)
.build();
IndyClientModule[] modules = new IndyClientModule[] {
new IndyFoloAdminClientModule(),
new IndyFoloContentClientModule(),
new IndyPromoteClientModule() };
indy = new Indy(siteConfig, authenticator, new IndyObjectMapper(true), modules);
indyMap.put(accessToken, indy);
} catch (IndyClientException e) {
throw new IllegalStateException("Failed to create Indy client: " + e.getMessage(), e);
}
}
return indy;
}