Okta Java SDK Client cache refresh


I am trying to use Client from java sdk for Okta to update some user attributes. I am using Clients.builder() with proper url, clientId, apiKey and scopes. Client is properly communicating with Okta server, reading and setting values from profile attributes.

The problem appears when in meantime, the profile attribute is changed in Okta admin panel. The instance of the client does not see that changes. Even after searching for user again using:


does not help. The values of attributes that I am getting with user.Profile.getString("attributeName") are from before the change in the panel. I am guessing that this is somehow cached.

The only solution that I found for it is to create a new instance of client. Is there any way to avoid this and refresh the client, cache or the DataStore or something like that?


Thanks in advance!


@mateuszr Hi, Please take a look of the discussion and solution from here Not sure if this is sth you are looking for.
When you run the test sample, you can also enable logging for com.okta.sdk.impl.ds.cache.DefaultResourceCacheStrategy and it will show cache hits as well.

@Lijia Hello, I am afraid this is not what I am looking for or I do not understand it or know how to implement it.

Current behaviour:

client = Clients.builder()
    .setScopes({"okta.users.read", "okta.users.manage"})
    .setClientCredentials(new TokenClientCredentials(apiKey))

print(client.getUser(userId).Profile.getString("attributeName")) // prints "123"

// here there is a change of the attribute in webpage admin panel for that user to "456"

print(client.getUser(userId).Profile.getString("attributeName")) // prints "123"

I would expect the second print to print “456”