예제 #1
0
        private async Task AuthLoginAsync()
        {
            _logger.LogTrace("AuthLoginAsync()");

            // Ignore the message bar : Allow Instagram Cookies
            await _seleniumWrapper.Click(_instagramOptions.CssCookiesWarning, canBeMissing : true);

            await _seleniumWrapper.InputWriteAsync(_instagramOptions.CssLoginEmail, _loggingOptions.User);

            if (!string.IsNullOrWhiteSpace(_loggingSecretOptions.Password))
            {
                await _seleniumWrapper.InputWriteAsync(_instagramOptions.CssLoginPassword, _loggingSecretOptions.Password);

                await _seleniumWrapper.EnterKeyAsync(_instagramOptions.CssLoginPassword);
            }
            else
            {
                _logger.LogInformation("Waiting user manual password validation...");
                _logger.LogWarning("PRESS <ENTER> WHEN LOGGED");
                Console.ReadLine();
            }

            // Humain user need to login with email code check ? In this case, remove password from the config and increase a lot step time (~1min) in order to allow you to pass throu this check process
            _seleniumWrapper.CrashIfPresent(_instagramOptions.CssLoginUnusual, InstagramOptions.CssLoginUnusualErrorMessage);

            // Confirm save user info
            await _seleniumWrapper.Click(_instagramOptions.CssLoginSageInfo, canBeMissing : true);

            // Ignore the enable notification on your browser modal popup
            await _seleniumWrapper.Click(_instagramOptions.CssLoginWarning, canBeMissing : true);

            // who am i ?
            await _seleniumWrapper.Click(_instagramOptions.CssHeaderMyself);        // must be here, else the auth have failed

            await _seleniumWrapper.Click(_instagramOptions.CssHeaderMyselfProfile); // must be here, else the auth have failed

            // new session with user URL
            _persistenceManager.SetNewSession(_seleniumWrapper.CurrentUrl);

            _logger.LogDebug("User {0} authentified from password : {1}", _loggingOptions.User, _persistenceManager.Session.UserContactUrl);
        }