nathan-fiscaletti / schwab-api-js

A Node.js library for buying and selling securities programmatically on Charles Schwab.
MIT License
14 stars 7 forks source link

Timeouts on login screen #1

Open davidacrook opened 1 week ago

davidacrook commented 1 week ago

Hi,

Thank you so much for writing this!

I'm trying to get it to work on an Ubuntu VM, latest version and am getting timeouts on the #schwablmslogin locator. I couldn't get this far until I changed the browser type to chromium instead of firefox, but now I'm stuck. I've tried it multiple times on a Linux VM as well as in WSL and keep hitting the 30 second timeout. I looked at the schwab website and the schwablmslogin iframe is still there.

Thanks,

Dave

Log: 2024-06-19T19:38:30.475Z info: retrieving account information 2024-06-19T19:38:30.477Z debug: performing HTTP GET request with authentication: https://client.schwab.com/api/PositionV2/PositionsDataV2 2024-06-19T19:38:30.477Z debug: authenticating request with options: {"loginIfRequired":true,"rememberDevice":true} 2024-06-19T19:38:30.477Z info: login required, attempting login 2024-06-19T19:38:30.478Z debug: initializing chromium browser with headless: true 2024-06-19T19:38:31.065Z debug: initializing new context with user agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36 2024-06-19T19:38:31.115Z debug: initializing new page with viewport: {"width":1920,"height":1080} 2024-06-19T19:38:34.804Z debug: navigating to : https://www.schwab.com/ 2024-06-19T19:38:35.733Z debug: waiting for login frame : #schwablmslogin 2024-06-19T19:39:05.738Z info: failed to retrieve account information: TimeoutError: page.waitForSelector: Timeout 30000ms exceeded. Call log:

2024-06-19T19:39:05.738Z error: Retrieving account information was not successful. 2024-06-19T19:39:05.738Z error: The attempt to retrieve account information produced the following error: 2024-06-19T19:39:05.738Z error: page.waitForSelector: Timeout 30000ms exceeded. Call log:

nathan-fiscaletti commented 1 week ago

Hey, curious question. Is this a headless VM? If it is not a headless VM, can you try adding the headless: false option to the Schwab constructor to open the browser while it performs the authentication? It might make it a little more clear what's happening.

const schwab = new Schwab({
    username: 'your-username',
    password: 'your-password',
    headless: false,
});
davidacrook commented 1 week ago

Thank you for the quick response and the tip about headless: false! I set headless: false and login fields are visible but program doesn't recognize them, even though I can see the id it's waiting on in the source. Logging in manually through the launched browser works in WSL but not Ubuntu, but doesn't help the program as it's still waiting on the login fields.

WSL: Successful login in browser outside of program. Using headless=false in program opens browser, login fields visible and cursor is on userid. Program never recognizes login fields and times out. Logging into the browser started by the program with headless=false works, but program still times out waiting for login fields.

Ubuntu 24.04 VM: Successful login in browser outside of program. Using headless=false in program opens browser, login fields visible and cursor is on userid. Program never recognizes login fields and times out. Logging into the browser started by the program with headless=false doesn't work and displays "We're unable to authorize your access."