コード例 #1
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;
            }
        }