MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / install_token_slot

Function install_token_slot

crates/openshell-core/src/grpc_client.rs:83–94  ·  view source on GitHub ↗
(token: &str)

Source from the content-addressed store, hash-verified

81}
82
83fn install_token_slot(token: &str) -> Result<TokenSlot> {
84 let bearer = AsciiMetadataValue::try_from(format!("Bearer {token}"))
85 .into_diagnostic()
86 .wrap_err("sandbox JWT contained characters not valid for a header value")?;
87 if let Some(existing) = TOKEN_SLOT.get() {
88 *existing.write().expect("token slot poisoned") = bearer;
89 return Ok(existing.clone());
90 }
91 let slot: TokenSlot = Arc::new(RwLock::new(bearer));
92 let _ = TOKEN_SLOT.set(slot.clone());
93 Ok(TOKEN_SLOT.get().cloned().unwrap_or(slot))
94}
95
96/// gRPC interceptor that injects `authorization: Bearer <token>` on every
97/// outbound request. The token lives in a shared [`TokenSlot`] so the renewal

Callers 1

token_slotFunction · 0.85

Calls 3

getMethod · 0.45
writeMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected