feat(auth): add StoredCredentials::new() constructor (#778)

StoredCredentials is #[non_exhaustive] but has no constructor, making
it impossible for external crates implementing CredentialStore to
construct instances without a serde roundtrip workaround. Add a new()
constructor matching the pattern used for other #[non_exhaustive]
types in this crate.

Fixes #777
This commit is contained in:
Will Pfleger 2026-03-27 14:47:41 -04:00 committed by GitHub
parent ac749e3ced
commit b74f5ca35b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -84,6 +84,23 @@ impl std::fmt::Debug for StoredCredentials {
}
}
impl StoredCredentials {
/// Create a new `StoredCredentials` instance.
pub fn new(
client_id: String,
token_response: Option<OAuthTokenResponse>,
granted_scopes: Vec<String>,
token_received_at: Option<u64>,
) -> Self {
Self {
client_id,
token_response,
granted_scopes,
token_received_at,
}
}
}
/// Trait for storing and retrieving OAuth2 credentials
///
/// Implementations of this trait can provide custom storage backends