File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -65,8 +65,14 @@ impl Token {
65
65
///
66
66
/// This takes an additional 30s margin to ensure the token can still be reasonably used
67
67
/// 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.
68
74
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 ( )
70
76
}
71
77
72
78
/// Get str representation of the token.
You can’t perform that action at this time.
0 commit comments