So I am using Selenium to login to a website that requires 2 factor authentication. Here are my steps locally(on my PC) and on the server.
Local: I manually open Chrome, authenticate through the 3rd party website, which saves the cookie/token in my browser data, then I can run Selenium through my Visual Studio localhost, run my code that does the login process and the site recognizes that my browser has already been authenticated(reads the cookies from my user profile) and does not prompt me for 2 factor authentication.
Server: I manually open Chrome, authenticate through the 3rd party website, which saves the cookie/token in my browser data, then I browse to my web app(I have tried locally on the server and from my PC, same results) and I am again prompted for the 2 factor authentication. I re-authenticate manually, close the browser, reopen it(manually) to verify that it wont prompt me again, it works, great! Then go back over to the application, try to run the login process again and it prompts me for 2 factor auth.
My Theory: 1. It is not loading the user profile specified. BUT I can't figure out why. Again, works fine on my local PC.
ChromeOptions options = new ChromeOptions();
options.AddArguments(@"--user-data-dir=C:\Users\UserName\AppData\Local\Google\Chrome\User Data");
options.AddArguments("--disable-gpu");
ChromeDriver cd = new ChromeDriver(@"C:\path\pathtoExe\", options);