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