The current authentication scheme renews the auth token once it is expired and a new request is made via BuildAuthenticationHeader() and CloudFoundryClient.GenerateAuthorizationToken().
CloudFoundryClient.GenerateAuthorizationToken() should probably not use the Token.IsExpired property but instead determine expiry based on Token.Expires in combination with a grace period like:
var now = DateTime.Now;
var renewalMargin = TimeSpan.FromMinutes( 1 );
var renewAt = Token.Expires.Subtract( renewalMargin );
bool needsRenew = now > renewAt
The current authentication scheme renews the auth token once it is expired and a new request is made via
BuildAuthenticationHeader()
andCloudFoundryClient.GenerateAuthorizationToken()
.Unfortunately this does not account for the fact that the token may expire after the request is built but before it hits the remote CF Api. The java client uses a grace period of 50s for this, i.e. the token is renewed well before it expires: https://github.com/cloudfoundry/cf-java-client/pull/61/files#diff-36fcc6fd3cf665b5f3300efa12c78437R396
CloudFoundryClient.GenerateAuthorizationToken()
should probably not use theToken.IsExpired
property but instead determine expiry based onToken.Expires
in combination with a grace period like: