Skip to content

Commit 75e1e93

Browse files
valkumdjc
authored andcommitted
Reduce expiry delta from 30s to 20s
The Python SDK states that the delta should be capped at 30s and the Go SDK uses 0s.
1 parent 49a813b commit 75e1e93

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/types.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,14 @@ impl Token {
6565
///
6666
/// This takes an additional 30s margin to ensure the token can still be reasonably used
6767
/// instead of expiring right after having checked.
68+
///
69+
/// Note:
70+
/// The official Python implementation uses 20s and states it should be no more than 30s.
71+
/// The official Go implementation uses 10s (0s for the metadata server).
72+
/// The docs state, the metadata server caches tokens until 5 minutes before expiry.
73+
/// We use 20s to be on the safe side.
6874
pub fn has_expired(&self) -> bool {
69-
self.inner.expires_at - Duration::seconds(30) <= OffsetDateTime::now_utc()
75+
self.inner.expires_at - Duration::seconds(20) <= OffsetDateTime::now_utc()
7076
}
7177

7278
/// Get str representation of the token.

0 commit comments

Comments
 (0)