class Google::Cloud::Env::ComputeMetadata
def identity_token_lifetime data
- Private: -
def identity_token_lifetime data return 0 unless data =~ /^[\w=-]+\.([\w=-]+)\.[\w=-]+$/ base64 = Base64.urlsafe_decode64 Regexp.last_match[1] json = JSON.parse base64 rescue nil return 0 unless json.respond_to?(:key?) && json&.key?("exp") lifetime = json["exp"].to_i - Time.now.to_i - TOKEN_EXPIRY_BUFFER lifetime = 0 if lifetime.negative? lifetime end