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 login on node.js #44

Closed
bkozlik opened this issue Feb 13, 2022 · 4 comments
Closed

Unable to login on node.js #44

bkozlik opened this issue Feb 13, 2022 · 4 comments

Comments

@bkozlik
Copy link

bkozlik commented Feb 13, 2022

Hi, I am having trouble getting the login flow to work on node.js.
I copied the sample code you shared in a comment on issue #19, using a locally generated certificate/private key + API_KEY. Everything compiles and runs.
When the login() routine is invoked, it opens up my default web browser to the TD Ameritrade login page and 1. asks for my account credentials and 2. asks if I want to grant my app permission to access to my account. After a successful auth / grant, the browser is redirected to my REDIRECT_URI (e.g. https://localhost/?code=.....) but the node.js app just sits there. I tried closing the browser tab and the entire browser, but the node.js app just sits there, apparently not receiving back what it needs from the browser.
What am I missing here?

Please note I am using Windows 10, I am not sure if this matters for how your library handles this login process. The redirect also appears to be changing my REDIRECT_URI from HTTP to HTTPS so it fails to actually load my local app. Not sure if either of these factors are relevant here but I thought I'd mention both.

Thanks in advance, I'm looking forward to resolving these issues and working with this library.

@knicola
Copy link
Owner

knicola commented Feb 14, 2022

Hello,

HTTPS is required for OAuth2 authentication. There's instructions in the readme on how to generate a self signed SSL cert. Also, both the local config and the TD App in your TD dev account should point to the same address. Hope this helps!

@bkozlik
Copy link
Author

bkozlik commented Feb 21, 2022

Hi @knicola , thanks for the reply.
Ok I took another crack at this and got the SSL certificate generated, installed into the Windows certificate store and accepted by the Microsoft Edge browser.
Now, the app takes me through the login/grant flow and then gets the code returned to https://localhost:8443/?code=.... but then displays a "Failed to get access token" message, while the node.js app crashes with the following error:

node:internal/process/promises:246
          triggerUncaughtException(err, true /* fromPromise */);
          ^

Error: write EPROTO B0510000:error:0A000152:SSL routines:final_renegotiate:unsafe legacy renegotiation disabled:c:\ws\deps\openssl\openssl\ssl\statem\extensions.c:908:

    at WriteWrap.onWriteComplete [as oncomplete] (node:internal/stream_base_commons:98:16)

Node.js v17.1.0

Is this "SSL unsafe legacy renegotiation disabled" error something I can resolve by generating the certificate with a different openssl command?

Thanks!

@knicola
Copy link
Owner

knicola commented Feb 21, 2022

Hey, can you try running it with node v16?

@bkozlik
Copy link
Author

bkozlik commented Feb 22, 2022

Yes, that worked. Thanks for your help & creating this project!

@bkozlik bkozlik closed this as completed Feb 22, 2022
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