pub struct KimiCodeOAuth { /* private fields */ }Expand description
Kimi Code OAuth handler using OAuth 2.0 device flow.
Implementations§
Source§impl KimiCodeOAuth
impl KimiCodeOAuth
Sourcepub fn with_endpoints(device_auth_url: String, token_url: String) -> Self
pub fn with_endpoints(device_auth_url: String, token_url: String) -> Self
Create with custom endpoints (for testing with a mock server).
Request a device authorization.
Sourcepub async fn request_device_token(
&self,
device_code: &str,
) -> Result<(u16, HashMap<String, Value>)>
pub async fn request_device_token( &self, device_code: &str, ) -> Result<(u16, HashMap<String, Value>)>
Poll the token endpoint for a device code.
Sourcepub async fn exchange_code(&self, code: &str) -> Result<OAuthCredential>
pub async fn exchange_code(&self, code: &str) -> Result<OAuthCredential>
Exchange an authorization code for access + refresh tokens.
Sourcepub async fn refresh_token(
&self,
refresh_token: &str,
) -> Result<OAuthCredential>
pub async fn refresh_token( &self, refresh_token: &str, ) -> Result<OAuthCredential>
Refresh an expired OAuth token.
Sourcepub async fn login<F, G>(
&self,
open_url: F,
print_message: G,
) -> Result<OAuthCredential>
pub async fn login<F, G>( &self, open_url: F, print_message: G, ) -> Result<OAuthCredential>
Full device-flow login: get device code, open browser, poll for token.
open_url is called with the verification URL to open in the browser.
print_message is called with status messages for the user.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for KimiCodeOAuth
impl RefUnwindSafe for KimiCodeOAuth
impl Send for KimiCodeOAuth
impl Sync for KimiCodeOAuth
impl Unpin for KimiCodeOAuth
impl UnsafeUnpin for KimiCodeOAuth
impl UnwindSafe for KimiCodeOAuth
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more