gcloud-identity-token 0.2.0

A secure OAuth token client for Google Cloud
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
use std::sync::OnceLock;

static PORT: OnceLock<u16> = OnceLock::new();

pub fn get_or_init_port() -> u16 {
    *PORT.get_or_init(|| {
        std::net::TcpListener::bind("127.0.0.1:0")
            .expect("Failed to bind to ephemeral port")
            .local_addr()
            .unwrap()
            .port()
    })
}