Esempio n. 1
0
        public static async Task LinkAuthenticator()
        {
            var json                = "LOGGED IN SESSION JSON CONTENT";
            var mobileSession       = JsonConvert.DeserializeObject <MobileSession>(json);
            var webAccess           = new SteamMobileWebAccess(mobileSession);
            var authenticatorLinker = new AuthenticatorLinker(webAccess);

            var authenticator = await authenticatorLinker.RequestToAddAuthenticator();

            // We just got a valid authenticator data
            // We should serialize and save this instance before doing anything else
            authenticator.SerializeToFile("MyAuthenticator.maFile2");

            // To accept and finalize this authenticator we need to have hold of the
            // text message sent to the account's associated phone number
            var smsCode = "SMS CODE HERE";

            try
            {
                await authenticatorLinker.FinalizeAddAuthenticator(authenticator, smsCode);

                // Authenticator finalized
            }
            catch (AuthenticatorLinkerException e)
            {
                if (e.ErrorCode == AuthenticatorLinkerErrorCode.BadSMSCode)
                {
                    // Bad SMS code
                    throw;
                }
            }
        }
Esempio n. 2
0
        public static async Task AddPhoneToAccount()
        {
            var json                = "LOGGED IN SESSION JSON CONTENT";
            var mobileSession       = JsonConvert.DeserializeObject <MobileSession>(json);
            var webAccess           = new SteamMobileWebAccess(mobileSession);
            var authenticatorLinker = new AuthenticatorLinker(webAccess);

            if (await authenticatorLinker.DoesAccountHasPhoneNumber())
            {
                // The account already has a phone number
                return;
            }

            var phoneNumber = "+98000000000";

            if (!await authenticatorLinker.RequestToAddPhoneNumber(phoneNumber))
            {
                // Request to add the phone number to account failed
                return;
            }

            // To accept and finalize this authenticator we need to have hold of the
            // text message sent to the account's associated phone number
            var smsCode = "SMS CODE HERE";

            if (!await authenticatorLinker.VerifyPhoneNumberBySMS(smsCode))
            {
                // Failed to finalize and verify added phone number
                // Probably bad SMS code; should try again
                return;
            }
        }