Struct steam_mobile::SteamAuthenticator
source · pub struct SteamAuthenticator<AuthState, MaFileState> { /* private fields */ }Expand description
Main authenticator. We use it to spawn and act as our “mobile” client. Responsible for accepting/denying trades, and some other operations that may or not be related to mobile operations.
§Example: Fetch mobile notifications
use steam_mobile::SteamAuthenticator;
use steam_mobile::User;Implementations§
source§impl<MaFileState> SteamAuthenticator<Unauthenticated, MaFileState>
impl<MaFileState> SteamAuthenticator<Unauthenticated, MaFileState>
sourcepub fn new(user: SteamUser<MaFileState>) -> Self
pub fn new(user: SteamUser<MaFileState>) -> Self
Returns current user API Key.
Will return None if you are not logged in.
sourcepub async fn login(
self
) -> Result<SteamAuthenticator<Authenticated, MaFileState>, AuthError>
pub async fn login( self ) -> Result<SteamAuthenticator<Authenticated, MaFileState>, AuthError>
Log on into Steam website and populates the inner client with cookies for the Steam Store, Steam community and Steam help domains.
Automatically unlocks parental control if user uses it, but it need to be included inside the SteamUser builder.
The mobile client also has a very simple exponential retry strategy for errors that are probably
caused by fast requests, so we retry it. For errors such as bad credentials, or inserting captcha
the proper errors are raised by AuthError.
Also caches the API Key, if the user wants to use it for any operation later.
The cookies are inside the [MobileClient] inner cookie storage.
source§impl<M> SteamAuthenticator<Authenticated, M>
impl<M> SteamAuthenticator<Authenticated, M>
sourcepub fn api_key(&self) -> Option<String>
pub fn api_key(&self) -> Option<String>
Returns account’s API Key, if authenticator managed to cache it.
sourcepub async fn steam_guard_status(&self) -> Result<QueryStatusResponse, AuthError>
pub async fn steam_guard_status(&self) -> Result<QueryStatusResponse, AuthError>
Returns this account SteamGuard information.
sourcepub async fn add_authenticator(
&self,
current_step: AddAuthenticatorStep,
phone_number: &str
) -> Result<AddAuthenticatorStep, AuthError>
pub async fn add_authenticator( &self, current_step: AddAuthenticatorStep, phone_number: &str ) -> Result<AddAuthenticatorStep, AuthError>
Add an authenticator to the account. Note that this makes various assumptions about the account.
The first argument is an enum of AddAuthenticatorStep to help you automate the process of adding an
authenticator to the account.
First call this method with AddAuthenticatorStep::InitialStep. This requires the account to be
already connected with a verified email address. After this step is finished, you will receive an email
about the phone confirmation.
Once you confirm it, you will call this method with AddAuthenticatorStep::EmailConfirmation.
This will return a AddAuthenticatorStep::MobileAuthenticatorFile now, with your maFile inside the variant.
For more complete example, you can check the CLI Tool, that performs the inclusion of an authenticator
interactively.
sourcepub async fn finalize_authenticator(
&self,
mafile: &MobileAuthFile,
sms_code: &str
) -> Result<(), AuthError>
pub async fn finalize_authenticator( &self, mafile: &MobileAuthFile, sms_code: &str ) -> Result<(), AuthError>
Finalize the authenticator process, enabling SteamGuard for the account.
This method wraps up the whole process, finishing the registration of the phone number into the account.
- EXTREMELY IMPORTANT *
Call this method ONLY after saving your maFile, because otherwise you WILL lose access to your account.
sourcepub async fn remove_authenticator(
&self,
revocation_code: &str,
remove_authenticator_scheme: RemoveAuthenticatorScheme
) -> Result<(), AuthError>
pub async fn remove_authenticator( &self, revocation_code: &str, remove_authenticator_scheme: RemoveAuthenticatorScheme ) -> Result<(), AuthError>
Remove an authenticator from a Steam Account.
Sets account to use SteamGuard email confirmation codes or even remove it completely.
sourcepub async fn request_custom_endpoint<T>(
&self,
url: String,
method: Method,
custom_headers: Option<HeaderMap>,
data: Option<T>
) -> Result<Response, InternalError>
pub async fn request_custom_endpoint<T>( &self, url: String, method: Method, custom_headers: Option<HeaderMap>, data: Option<T> ) -> Result<Response, InternalError>
You can request custom operations for any Steam operation that requires logging in.
The authenticator will take care sending session cookies and keeping the session operational.
source§impl SteamAuthenticator<Authenticated, PresentMaFile>
impl SteamAuthenticator<Authenticated, PresentMaFile>
sourcepub async fn fetch_confirmations(&self) -> Result<Confirmations, AuthError>
pub async fn fetch_confirmations(&self) -> Result<Confirmations, AuthError>
Fetch all confirmations available with the authenticator.
sourcepub async fn handle_confirmations<'a, 'b, F>(
&self,
operation: ConfirmationAction,
f: F
) -> Result<(), AuthError>
pub async fn handle_confirmations<'a, 'b, F>( &self, operation: ConfirmationAction, f: F ) -> Result<(), AuthError>
Fetches confirmations and process them.
f is a function which you can use it to filter confirmations at the moment of the query.
sourcepub async fn process_confirmations<I>(
&self,
operation: ConfirmationAction,
confirmations: I
) -> Result<(), AuthError>where
I: IntoIterator<Item = Confirmation> + Send,
pub async fn process_confirmations<I>(
&self,
operation: ConfirmationAction,
confirmations: I
) -> Result<(), AuthError>where
I: IntoIterator<Item = Confirmation> + Send,
Trait Implementations§
Auto Trait Implementations§
impl<AuthState, MaFileState> !RefUnwindSafe for SteamAuthenticator<AuthState, MaFileState>
impl<AuthState, MaFileState> Send for SteamAuthenticator<AuthState, MaFileState>
impl<AuthState, MaFileState> Sync for SteamAuthenticator<AuthState, MaFileState>
impl<AuthState, MaFileState> Unpin for SteamAuthenticator<AuthState, MaFileState>
impl<AuthState, MaFileState> !UnwindSafe for SteamAuthenticator<AuthState, MaFileState>
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
source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.