pub struct AuthClient { /* private fields */ }Expand description
OAuth2 authorization client for Ppoppo Accounts.
Implementations§
Source§impl AuthClient
impl AuthClient
Sourcepub fn try_new(config: OAuthConfig) -> Result<Self, Error>
pub fn try_new(config: OAuthConfig) -> Result<Self, Error>
Create a new Ppoppo Accounts auth client.
Returns an error iff reqwest::Client::builder() cannot construct a
client with the configured timeouts (TLS init failure, OS-level
resource exhaustion). The previous unwrap_or_default() path silently
substituted a no-timeout client, which converted a startup failure
into a runtime hang on the first PAS call — fail loudly instead.
§Errors
Returns Error::Http if the underlying HTTP client cannot be built.
Sourcepub fn with_http_client(config: OAuthConfig, client: Client) -> Self
pub fn with_http_client(config: OAuthConfig, client: Client) -> Self
Build with a caller-supplied HTTP client.
Use this when sharing a reqwest::Client across multiple SDK clients
for connection-pool reuse, or when you need custom TLS / proxy / timeout
configuration. This constructor never fails.
Generate an authorization URL with PKCE parameters.
Sourcepub async fn exchange_code(
&self,
code: &str,
code_verifier: &str,
) -> Result<TokenResponse, Error>
pub async fn exchange_code( &self, code: &str, code_verifier: &str, ) -> Result<TokenResponse, Error>
Exchange an authorization code for tokens using PKCE.
§Errors
Returns Error::Http on network failure, or
Error::OAuth if the token endpoint returns an error.
Sourcepub async fn refresh_token(
&self,
refresh_token: &str,
) -> Result<TokenResponse, Error>
pub async fn refresh_token( &self, refresh_token: &str, ) -> Result<TokenResponse, Error>
Exchange a refresh token for new tokens.
§Errors
Returns Error::Http on network failure, or
Error::OAuth if the token endpoint returns an error.
Sourcepub async fn get_user_info(&self, access_token: &str) -> Result<UserInfo, Error>
pub async fn get_user_info(&self, access_token: &str) -> Result<UserInfo, Error>
Fetch user info using an access token.
§Errors
Returns Error::Http on network failure, or
Error::OAuth if the userinfo endpoint returns an error.