Skip to content
Anoncer edited this page Aug 10, 2022 · 39 revisions

Connection

Currently there are only two types of connection:

The connection is made in the following way: import SteamAuth;

Authorization

To work with Steam Guard and confirm trades, you need to log in for further actions.

For this we use the class UserLogin

new UserLogin(username:string, password:string)

  • username:string - Credentials for Steam
  • password:string - Credentials for Steam

Example

//Credentials for Steam
string username = “”;
string password = “”;

//Class initialization
UserLogin login = new UserLogin(username, password);

Login

During authorization on Steam, it may require various account confirmations.

  • NeedCaptcha

This response sends a link to the captcha image. If this response is received, then a unique text is received in CaptchaGID.

To get a link use: APIEndpoints.COMMUNITY_BASE + "/public/captcha.php?gid=" + login.CaptchaGID

Then you need to pass the code from the image to CaptchaText

login.CaptchaText = captchaText; captchaText - сode from the picture

//Attempt to login
LoginResult response = login.DoLogin();

if(response == LoginResult.NeedCaptcha)
{
     //Open a web browser to the captcha image
     System.Diagnostics.Process.Start(APIEndpoints.COMMUNITY_BASE + "/public/captcha.php?gid=" + login.CaptchaGID); 
     string captchaText = Console.ReadLine(); 
     login.CaptchaText = captchaText;
     response = login.DoLogin();
}
  • Need2FA

This answer means that Steam Guard is enabled on this account and it asks to code.

Then you need to pass the code from Steam Guard to TwoFactorCode

//Attempt to login
LoginResult response = login.DoLogin();

if(response == LoginResult.Need2FA)
{
     string code = Console.ReadLine(); 
     login.TwoFactorCode = code;
     response = login.DoLogin();
}
  • NeedEmail

This response means that a code was sent to the user's mail to verify the account.

Then you need to pass the code from mail to EmailCode

//Attempt to login
LoginResult response = login.DoLogin();

if(response == LoginResult.NeedEmail)
{
     string code = Console.ReadLine(); 
     login.EmailCode = code;
     response = login.DoLogin();
}

Function DoLogin() which is used in the class UserLogin returns parameter LoginResult

LoginResult response = login.DoLogin();

Example

LoginResult response = LoginResult.BadCredentials;
while ((response = login.DoLogin()) != LoginResult.LoginOkay)
{
     switch (response)
     {
          case LoginResult.NeedEmail:
             Console.WriteLine("Please enter your email code: ");
             string code = Console.ReadLine();
             login.EmailCode = code;
             break;

          case LoginResult.NeedCaptcha:
             System.Diagnostics.Process.Start(APIEndpoints.COMMUNITY_BASE + "/public/captcha.php?gid=" + login.CaptchaGID);
             Console.WriteLine("Please enter captcha text: ");
             string captchaText = Console.ReadLine();
             login.CaptchaText = captchaText;
             break;

          case LoginResult.Need2FA:
             Console.WriteLine("Please enter your mobile authenticator code: ");
             code = Console.ReadLine();
             login.TwoFactorCode = code;
             break;
     }
}

Add Steam Guard

After LoginResult returned LoginOkay, you can connect Steam Guard to this account with saving the cipher key.

To do this, you need to use the AuthenticatorLinker class.

When the class is initialized, the login.Session argument is passed.

AuthenticatorLinker linker = new AuthenticatorLinker(login.Session);

⚠️ Important! ⚠️ To enable Steam Guard,user account must have a phone number associated with it. When adding Steam Guard, an SMS code will be sent to the user's phone.

Everything is fine, there is a check on the phone.

In AuthenticatorLinker we need 2 functions:

  • AddAuthenticator
  • FinalizeAddAuthenticator

AddAuthenticator

FinalizeAddAuthenticator

Can be executed after AddAuthenticator

Clone this wiki locally