pub struct ApiCredentials {
pub client_id: Option<String>,
pub client_secret: Option<String>,
}Expand description
API credentials for authentication
Fields§
§client_id: Option<String>Client ID for OAuth2
client_secret: Option<String>Client secret for OAuth2
Implementations§
Source§impl ApiCredentials
impl ApiCredentials
Sourcepub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
Validates whether the required fields client_id and client_secret are present.
§Returns
true- If bothclient_idandclient_secretareSome(i.e., notNone).false- If eitherclient_idorclient_secretisNone.
Sourcepub fn new() -> Result<Self, HttpError>
pub fn new() -> Result<Self, HttpError>
Creates a new instance of the struct with credentials initialized from environment variables.
§Returns
Ok(Self): If the credentials are properly configured and valid.Err(HttpError::ConfigError): If the credentials are not properly set or invalid, with an appropriate error message indicating the configuration issue.
§Note
- If the credentials are invalid or not set, a warning will be logged, and only public API endpoints will be accessible.
Sourcepub fn get_client_credentials(&self) -> Result<(String, String), HttpError>
pub fn get_client_credentials(&self) -> Result<(String, String), HttpError>
Retrieves the client credentials (Client ID and Client Secret) required for OAuth2 authentication.
§Returns
Ok((String, String)): A tuple containing theclient_idandclient_secretif they are both set.Err(HttpError): An error of typeHttpError::ConfigErrorif eitherclient_idorclient_secretis not set.
§Errors
Returns an HttpError::ConfigError with a message indicating that both Client ID
and Client Secret must be set for OAuth2 authentication when either or both are absent.
§Note
This function assumes that client_id and client_secret are optional fields.
Ensure they are properly configured before invoking this function.
Trait Implementations§
Source§impl Clone for ApiCredentials
impl Clone for ApiCredentials
Source§fn clone(&self) -> ApiCredentials
fn clone(&self) -> ApiCredentials
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ApiCredentials
impl Debug for ApiCredentials
Source§impl Default for ApiCredentials
impl Default for ApiCredentials
Source§impl<'de> Deserialize<'de> for ApiCredentials
impl<'de> Deserialize<'de> for ApiCredentials
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for ApiCredentials
impl Display for ApiCredentials
Auto Trait Implementations§
impl Freeze for ApiCredentials
impl RefUnwindSafe for ApiCredentials
impl Send for ApiCredentials
impl Sync for ApiCredentials
impl Unpin for ApiCredentials
impl UnwindSafe for ApiCredentials
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.