use crate::authn::service::AuthnService;
use crate::authn::store::{FactorStore, IdentityStore};
impl<I, F> AuthnService<I, F>
where
I: IdentityStore,
F: FactorStore<Error = I::Error>,
{
#[tracing::instrument(skip(self, access_token))]
pub async fn fetch_userinfo(
&self,
provider_name: &str,
access_token: &str,
) -> Result<axess_factors::oauth::UserInfoClaims, axess_factors::oauth::OAuthError> {
use axess_factors::oauth::OAuthError;
if access_token.is_empty() {
return Err(OAuthError::NoAccessToken);
}
let provider = self
.oauth_providers
.get(provider_name)
.ok_or_else(|| OAuthError::UnknownProvider(provider_name.to_string()))?
.clone();
provider.fetch_userinfo(access_token).await
}
}