authx_plugins/oauth/providers/
mod.rs1pub mod github;
2pub mod google;
3
4use async_trait::async_trait;
5
6use authx_core::error::Result;
7
8#[derive(Debug, Clone)]
10pub struct OAuthTokens {
11 pub access_token: String,
12 pub refresh_token: Option<String>,
13 pub expires_in: Option<u64>,
15}
16
17#[derive(Debug, Clone)]
19pub struct OAuthUserInfo {
20 pub provider_user_id: String,
21 pub email: String,
22 pub name: Option<String>,
23}
24
25#[async_trait]
26pub trait OAuthProvider: Send + Sync {
27 fn name(&self) -> &'static str;
28
29 fn authorization_url(&self, state: &str, pkce_challenge: &str) -> String;
31
32 async fn exchange_code(
34 &self,
35 code: &str,
36 pkce_verifier: &str,
37 redirect_uri: &str,
38 ) -> Result<OAuthTokens>;
39
40 async fn fetch_user_info(&self, access_token: &str) -> Result<OAuthUserInfo>;
42}