Okta Java SDK Client cache refresh

Hello,

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:

client.getUser(userId)

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?

Versions:
com.okta.sdk:okta-sdk-api:3.0.3
com.okta.sdk:okta-sdk-impl:3.0.0
com.okta.sdk:okta-sdk-httpclient:3.0.3

Thanks in advance!

Br,
Mateusz

1 Like

@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()
    .setOrgUrl(url)
    .setClientId(clientId)
    .setScopes({"okta.users.read", "okta.users.manage"})
    .setClientCredentials(new TokenClientCredentials(apiKey))
    .build();

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”

1 Like

Any update on this? How were you able to get the updated profile value, without refreshing the client.