pub struct Auth { /* private fields */ }Expand description
Authentication manager for IG Markets API
Handles all authentication operations including:
- Login with API v2 or v3
- Automatic OAuth token refresh
- Account switching
- Session management
- Rate limiting for API requests
Implementations§
Source§impl Auth
impl Auth
Sourcepub fn new(config: Arc<Config>) -> Self
pub fn new(config: Arc<Config>) -> Self
Creates a new Auth instance
§Arguments
config- Configuration containing credentials and API settings
Sourcepub async fn get_ws_info(&self) -> WebsocketInfo
pub async fn get_ws_info(&self) -> WebsocketInfo
Gets the WebSocket password for Lightstreamer authentication
§Returns
- WebSocket password in format “CST-{cst}|XST-{token}” or empty string if session is not available
Sourcepub async fn get_session(&self) -> Result<Session, AppError>
pub async fn get_session(&self) -> Result<Session, AppError>
Gets the current session, ensuring tokens are valid
This method automatically refreshes expired OAuth tokens or re-authenticates if needed.
§Returns
Ok(Session)- Valid session with fresh tokensErr(AppError)- If authentication fails
Sourcepub async fn login(&self) -> Result<Session, AppError>
pub async fn login(&self) -> Result<Session, AppError>
Performs initial login to IG Markets API
Automatically detects API version from config and uses appropriate authentication method.
§Returns
Ok(Session)- Authenticated sessionErr(AppError)- If login fails
Sourcepub async fn refresh_token(&self) -> Result<Session, AppError>
pub async fn refresh_token(&self) -> Result<Session, AppError>
Refreshes an expired OAuth token with automatic retry on rate limit
If refresh fails (e.g., refresh token expired), performs full re-authentication.
§Returns
Ok(Session)- New session with refreshed tokensErr(AppError)- If refresh and re-authentication both fail
Auto Trait Implementations§
impl Freeze for Auth
impl !RefUnwindSafe for Auth
impl Send for Auth
impl Sync for Auth
impl Unpin for Auth
impl !UnwindSafe for Auth
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> 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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more