Ejemplo n.º 1
0
        public async Task <SteamGuardServiceResponse> SubmitEmailCode(string code)
        {
            _sessionService.EmailCode = code;
            var sessionStatus = await GetSessionStatus();

            switch (sessionStatus.status)
            {
            case SteamSessionCreateService.Status.NeedEmail:
                return(SteamGuardServiceResponse.WrongEmailCode);

            case SteamSessionCreateService.Status.Okay:
                return(SteamGuardServiceResponse.NeedSMSCode);

            case SteamSessionCreateService.Status.Need2FA:
                Error = SteamGuardServiceError.AllreadyConnectedSteamguard;
                return(SteamGuardServiceResponse.Error);

            case SteamSessionCreateService.Status.TooManyFailedLogins:
                Error = SteamGuardServiceError.LoginFailedTooOften;
                return(SteamGuardServiceResponse.Error);

            case SteamSessionCreateService.Status.BadRSA:
                Error = SteamGuardServiceError.RSAFailed;
                return(SteamGuardServiceResponse.Error);
            }
            return(SteamGuardServiceResponse.Error);
        }
Ejemplo n.º 2
0
        public async Task <SteamGuardServiceResponse> SubmitUsernamePassword(string username, string password)
        {
            _sessionService = new SteamSessionCreateService(username, password);
            var sessionStatus = await GetSessionStatus();

            switch (sessionStatus.status)
            {
            case SteamSessionCreateService.Status.Error_EmptyResponse:
                Error = SteamGuardServiceError.EmptyResponse;
                return(SteamGuardServiceResponse.Error);

            case SteamSessionCreateService.Status.NeedEmail:
                return(SteamGuardServiceResponse.NeedEmailCode);

            case SteamSessionCreateService.Status.NeedCaptcha:
                return(SteamGuardServiceResponse.NeedCaptcha);

            case SteamSessionCreateService.Status.BadCredentials:
                return(SteamGuardServiceResponse.WrongCredentials);

            case SteamSessionCreateService.Status.Need2FA:
                Error = SteamGuardServiceError.AllreadyConnectedSteamguard;
                return(SteamGuardServiceResponse.Error);

            case SteamSessionCreateService.Status.TooManyFailedLogins:
                Error = SteamGuardServiceError.LoginFailedTooOften;
                return(SteamGuardServiceResponse.Error);

            case SteamSessionCreateService.Status.BadRSA:
                Error = SteamGuardServiceError.RSAFailed;
                return(SteamGuardServiceResponse.Error);
            }
            return(SteamGuardServiceResponse.Error);
        }
Ejemplo n.º 3
0
        public async Task <SteamGuardServiceResponse> SubmitSMSCode(string code)
        {
            var postData = new NameValueCollection();

            postData.Add("steamid", _steamSession.SteamID.ToString());
            postData.Add("access_token", _steamSession.OAuthToken);
            postData.Add("activation_code", code);
            int tries = 0;

            while (tries <= 30)
            {
                postData.Set("authenticator_code", _steamGuardData.GenerateSteamGuardCode());
                postData.Set("authenticator_time", SteamTimeSyncHelper.GetSteamUnixTime().ToString());

                string response = await SteamWebHelper.MobileLoginRequest(SteamAPIEndpoints.STEAMAPI_BASE + "/ITwoFactorService/FinalizeAddAuthenticator/v0001", "POST", postData);

                if (response == null)
                {
                    Error = SteamGuardServiceError.EmptyResponse;
                    return(SteamGuardServiceResponse.Error);
                }

                var finalizeResponse = JsonConvert.DeserializeObject <FinalizeAuthenticatorResponse>(response);

                if (finalizeResponse == null || finalizeResponse.Response == null)
                {
                    Error = SteamGuardServiceError.CorruptResponse;
                    return(SteamGuardServiceResponse.Error);
                }

                if (finalizeResponse.Response.Status == 89)
                {
                    return(SteamGuardServiceResponse.WrongSMSCode);
                }

                if (finalizeResponse.Response.Status == 88)
                {
                    if (tries >= 30)
                    {
                        Error = SteamGuardServiceError.GuardSyncFailed;
                        return(SteamGuardServiceResponse.Error);
                    }
                }

                if (!finalizeResponse.Response.Success)
                {
                    Error = SteamGuardServiceError.SuccessMissing;
                    return(SteamGuardServiceResponse.Error);
                }

                if (finalizeResponse.Response.WantMore)
                {
                    tries++;
                    continue;
                }

                return(SteamGuardServiceResponse.Okay);
            }

            Error = SteamGuardServiceError.General;
            return(SteamGuardServiceResponse.Error);
        }