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>
where MaFileState: 'static + Send + Sync + Clone,

source

pub fn new(user: SteamUser<MaFileState>) -> Self

Returns current user API Key.

Will return None if you are not logged in.

source

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>

source

pub fn api_key(&self) -> Option<String>

Returns account’s API Key, if authenticator managed to cache it.

source

pub async fn steam_guard_status(&self) -> Result<QueryStatusResponse, AuthError>

Returns this account SteamGuard information.

source

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.

source

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.

source

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.

source

pub async fn request_custom_endpoint<T>( &self, url: String, method: Method, custom_headers: Option<HeaderMap>, data: Option<T> ) -> Result<Response, InternalError>
where T: Serialize + Send + Sync,

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>

source

pub async fn fetch_confirmations(&self) -> Result<Confirmations, AuthError>

Fetch all confirmations available with the authenticator.

source

pub async fn handle_confirmations<'a, 'b, F>( &self, operation: ConfirmationAction, f: F ) -> Result<(), AuthError>
where F: Fn(Confirmations) -> Box<dyn Iterator<Item = Confirmation> + Send> + Send,

Fetches confirmations and process them.

f is a function which you can use it to filter confirmations at the moment of the query.

source

pub async fn process_confirmations<I>( &self, operation: ConfirmationAction, confirmations: I ) -> Result<(), AuthError>
where I: IntoIterator<Item = Confirmation> + Send,

Accept or deny confirmations.

§Panics

Will panic if not logged in with SteamAuthenticator first.

Trait Implementations§

source§

impl<AuthState: Debug, MaFileState: Debug> Debug for SteamAuthenticator<AuthState, MaFileState>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<AuthState, MaFileState> !RefUnwindSafe for SteamAuthenticator<AuthState, MaFileState>

§

impl<AuthState, MaFileState> Send for SteamAuthenticator<AuthState, MaFileState>
where AuthState: Send, MaFileState: Send,

§

impl<AuthState, MaFileState> Sync for SteamAuthenticator<AuthState, MaFileState>
where AuthState: Sync, MaFileState: Sync,

§

impl<AuthState, MaFileState> Unpin for SteamAuthenticator<AuthState, MaFileState>
where AuthState: Unpin, MaFileState: Unpin,

§

impl<AuthState, MaFileState> !UnwindSafe for SteamAuthenticator<AuthState, MaFileState>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> Downcast for T
where T: Any,

source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more