pub mod github;
pub mod google;
use async_trait::async_trait;
use authx_core::error::Result;
#[derive(Debug, Clone)]
pub struct OAuthTokens {
pub access_token: String,
pub refresh_token: Option<String>,
pub expires_in: Option<u64>,
}
#[derive(Debug, Clone)]
pub struct OAuthUserInfo {
pub provider_user_id: String,
pub email: String,
pub name: Option<String>,
}
#[async_trait]
pub trait OAuthProvider: Send + Sync {
fn name(&self) -> &'static str;
fn authorization_url(&self, state: &str, pkce_challenge: &str) -> String;
async fn exchange_code(
&self,
code: &str,
pkce_verifier: &str,
redirect_uri: &str,
) -> Result<OAuthTokens>;
async fn fetch_user_info(&self, access_token: &str) -> Result<OAuthUserInfo>;
}