File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -55,6 +55,30 @@ impl fmt::Debug for OAuth {
5555}
5656
5757impl OAuth {
58+ /// Create an OAuth client from a pre-existing access token.
59+ ///
60+ /// This is useful for server-side scenarios where the token is obtained
61+ /// externally (e.g., via an MCP OAuth proxy) and you need to construct
62+ /// an [`OAuth`] instance without going through the browser authorization
63+ /// flow.
64+ ///
65+ /// The returned instance does **not** support token refresh — calling
66+ /// [`access_token`](OAuth::access_token) simply returns the provided
67+ /// token until it expires.
68+ pub fn from_token ( access_token : impl Into < String > ) -> Self {
69+ let access_token = access_token. into ( ) ;
70+ Self ( Arc :: new ( OAuthInner {
71+ client_id : String :: new ( ) ,
72+ callback_port : DEFAULT_CALLBACK_PORT ,
73+ token : tokio:: sync:: Mutex :: new ( Some ( OAuthToken {
74+ client_id : String :: new ( ) ,
75+ access_token,
76+ refresh_token : None ,
77+ expires_at : u64:: MAX ,
78+ } ) ) ,
79+ } ) )
80+ }
81+
5882 /// Return the OAuth client ID
5983 pub fn client_id ( & self ) -> & str {
6084 & self . 0 . client_id
You can’t perform that action at this time.
0 commit comments