After authenticated I use access until it expires, but when it is expired it does not updated automcatically,
Do I need to check Access() is expired or not manually inside an other thread?
os = OSFactory.builder().endpoint("http://" + ip + ":5000/v2.0")
.perspective(Facing.ADMIN) //Container oluşturmak için
//.scopeToProject(projectIdentifier, domainIdentifier) V3 ile gelen bir özellik.
long delay = os.getAccess().getToken().getExpires().getTime() - System.currentTimeMillis();
User user = findUserByName("user1");
User user2 = findUserByName("user2");
Reauthentication should be triggered in case the code of the response is 401.
Could you check that's the case?
@auhlig yes reauthentication is triggered but newly taken token is only used by one request. For other request to be invoked, same steps are repeated.
I mean first token is used then having 401 error then taken new token to retry the request, I have updated my question by adding sample code portion. As you can see than I have added a delay to expire the token , after then invoking findUserByName() method , I am getting 401 so getting a new token then retring the request.
The problem is when I was invoking findUserByName("user2") I was expecting previous token would be used but I got 401 error then getting a new token . I have analyzed debug logs,
Understood. Renewed token only used for request. Original token still assigned to session.
Here https://github.com/ContainX/openstack4j/blob/master/connectors/http-connector/src/main/java/org/openstack4j/connectors/http/HttpExecutorServiceImpl.java#L61 we check if the response code is 401, in which case the we trigger re-authentication in ll. 64 and assign the new access to the current request https://github.com/ContainX/openstack4j/blob/master/connectors/http-connector/src/main/java/org/openstack4j/connectors/http/HttpExecutorServiceImpl.java#L65 .
The authentication-method should also assign the new access to the current session https://github.com/ContainX/openstack4j/blob/master/core/src/main/java/org/openstack4j/openstack/internal/OSAuthenticator.java#L116 .
Maybe it fails here somewhere.
Would you like to contribute and look into that? I would support.
I have found my faulth that I am always invoking "OSFactory.clientFromAccess(access);" before calling a request and using the same access token.
When I have used OSClient directly instead of OSFactory.clientFromAccess(os.getAccess(), Facing.ADMIN),
I see reauthentication is invoked successfully and newly token is used next request until it expires.
But I am trying to find a solution to a case that
How can I use a single os client with different facing, I need such a case that there many rest requests in a method AllinOneMethod(), some of which must be invoked by ADMIN facing some of which are invokde by null FACING.
No bug then 😅
Threading maybe. Can we close the issue, since there seems to be no bug? Maybe the google group or stackoverflow community can be of help.