Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to authenticate with tools/credentials_builder.py #30

Open
jeremyis78 opened this issue Jan 16, 2022 · 2 comments
Open

Unable to authenticate with tools/credentials_builder.py #30

jeremyis78 opened this issue Jan 16, 2022 · 2 comments

Comments

@jeremyis78
Copy link

I'm trying to get a credential file saved but having trouble.

As it was suggested as the easiest method, I'm using the python/tools credential_builder.py.
I ran the dependencies
python setup.py install (from project's python directory)
and
pip install cefpython3

Then I tried the credentials_builder.py and after it brings up the dialog and I enter creds, do 2FA, allow all the things, click Allow and then I get a blank page in that window and the credentials file is never saved as my ~/tda-creds is still a zero byte file. I'm getting the following (had to kill it to get it to stop); I tried this three times, same result (G...I is my edited Consumer Key):

`➜ tools git:(master) ✗ python credential_builder.py --redirect-uri http://127.0.0.1 [email protected] ~/tda-creds re******

  • Successfully loaded: libTDAmeritradeAPI.so
  • Last Build: Jan 15 2022 - 00:12:35
  • Extract Args...
  • Confirm password: re******
  • File already exists, overwrite? (yes/no): yes
    Library Path: N/A
    Redirect URI: http://127.0.0.1
    Client ID: [email protected]
    Credential Path: /Users/myuser/tda-creds
    Credential Password: re******

DevTools listening on ws://127.0.0.1:58598/devtools/browser/e8fe8456-08d9-4606-905f-b5c94c0af902
[0115/041242.037414:ERROR:BudgetService.cpp(160)] Unable to connect to the Mojo BudgetService.
[0115/041307.352655:ERROR:BudgetService.cpp(160)] Unable to connect to the Mojo BudgetService.
[0115/041309.341600:ERROR:BudgetService.cpp(160)] Unable to connect to the Mojo BudgetService.
[0115/041323.484688:ERROR:BudgetService.cpp(160)] Unable to connect to the Mojo BudgetService.
[0115/041341.099560:ERROR:BudgetService.cpp(160)] Unable to connect to the Mojo BudgetService.
^C`

My developer app at TDAmeritrade uses http://127.0.0.1.
I'm using Python 3.7.2. And I also built the library on MacOS (works great, btw) and installed it in /user/local/lib as both .so and .dylib (as the Java test/java/Test.java ends up looking for that extension on a Mac/Darwin; python finds the .so as seen above), not sure if that's an issue. Any idea what the issue is? Is this Mojo BudgetService an indicator of a problem?

I also tried opening tools/get-access-code.html in a browser but apparently I tried too many times with credential_builder.py as TDA says something like someone may be trying to log in to your account unauthorized; give us a call if you have questions.

@jeog
Copy link
Owner

jeog commented Jan 16, 2022

It's been a while since I used this script, but sounds like the RequestHandler is hanging. First thing I would do is add some debug print statements to the script inside of get_access_code_from_web_interface(...) and RequestHandler::OnResourceRedirect(...) to confirm its an issue with cefpython3. If that's not the issue you may be able to use the --access-code-out switch to dump the raw access code to a file.

If it is an issue w/ cefpython3 you'll probably need to use a different approach to get the access code, which I see you tried w/ get-access-code.html. If TDA is blocking it you may need to delete the developer app and create a new one. If you are able to get the access code manually you can create the credentials file w/ creds_from_access_code.py

@jeremyis78
Copy link
Author

jeremyis78 commented Jan 17, 2022

So I was able to see (partially) what's going on. When using the --redirect-uri set to http://127.0.0.1 I was NOT able to get past the line
if self._redirect_uri in new_url: and since there's no else to that if I'm not made aware as to what's going on. I added an else and found that the new_url was actually 'https://127.0.0.1/?code=oo6sqcbzH9...' and so that was why self.code = self._parse_redirect_url(new_url) was not being called (http vs https).

I changed my app at TDA to use https://127.0.0.1 and then called credential_builder.py without the redirect-uri and with a print statement to print the code directly after the parse line. The code was printed, but it appears control was never returned from the RequestHandler because a print statement for the code after code = get_access_code_from_web_interface(client_id, redirect_uri) in main() is never called. So it appears there may be some issue getting a credential file saved using just the credential_builder.py. I'm unsure the exact issue other than what I described. I'd be curious if this way of getting credentials works completely on linux; I tried on ubuntu 20.04 but had trouble getting python to load the shared library (libTDAmeritradeAPI.so). Does it work for you on linux, jeog?

I was able to grab the code and then use creds_from_access.py to create a credential file. I was then able to reference that credential file when running the Java test at test/java/Test.java.

Edit: I also tried using --access-code-out but it was hanging up before getting there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants