1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//! Tonic request interceptor that attaches `Authorization: Bearer <token>`
//! to every outgoing gRPC call.
//!
//! ## Usage
//!
//! ```ignore
//! use ppoppo_sdk_core::interceptor::{AuthInterceptor, BearerCredential};
//! use ppoppo_sdk_core::token_cache::TokenCache;
//!
//! // Fetch a fresh token from the cache (async), then create the interceptor.
//! let token: String = cache.get().await?;
//! let cred = BearerCredential::new(token);
//! let interceptor = AuthInterceptor::new(cred);
//!
//! // Attach to any tonic service client:
//! let client = MyServiceClient::with_interceptor(channel, interceptor);
//! ```
//!
//! The interceptor is synchronous — tonic's `Interceptor::call` has no async
//! capability. Token refresh is the caller's responsibility (done before each
//! call via `TokenCache::get`).
use ;
/// A raw Bearer JWT string. Newtypes it from plain `String` so call sites
/// are explicit about what they're passing around.
;
/// Tonic [`Interceptor`] that injects `Authorization: Bearer <token>` into
/// every outgoing request's metadata.
///
/// Constructed from a [`BearerCredential`] obtained via `TokenCache::get`.
/// One instance per RPC call — create it fresh each time so the token is
/// always current.
;