Closed
Description
Describe the bug
OAuth2AccessTokenResponse doesn't use values provided to expiresIn()
method when it was originally built from a previous response (through the withResponse()
method).
Expected behavior
The newly created token response should update expiresAt
using the value the provided to expiresIn()
, or maybe throw an exception if keeping the original expiresAt
value is done on purpose.
Sample
@Test
public void test() {
var sourceTokenResponse = OAuth2AccessTokenResponse.withToken("abcd")
.tokenType(OAuth2AccessToken.TokenType.BEARER)
.expiresIn(10)
.build();
var modifiedTokenResponse = OAuth2AccessTokenResponse
.withResponse(sourceTokenResponse)
.expiresIn(60)
.build();
Assertions.assertEquals(
modifiedTokenResponse.getAccessToken().getIssuedAt().plusSeconds(60),
modifiedTokenResponse.getAccessToken().getExpiresAt());
}
Note
May be linked to #8696 ?