tedchou12 / webull

Unofficial APIs for Webull.
MIT License
597 stars 181 forks source link

Login issue #366

Closed sabujhh closed 1 year ago

sabujhh commented 1 year ago

I am trying to login. But it says access token is expired even though I gave the correct MFA.

{'msg': 'AccessToken is expire', 'traceId': '431d6e8ff1b743628209e838bc3dd94a', 'code': 'auth.token.expire'}

My code is :

from webull import paper_webull

wb = paper_webull()

wb.get_mfa('') mfa_code = input("MFA Code: ") print(wb.get_security('')) answer = input("Security Question Answer: ") question_id = input("Question : ")

wb.login('', '', '', mfa_code, question_id, answer)

print(wb.get_trade_token('')) wb.place_order(stock='SNAP', price=50.0, quant=1) orders = wb.get_current_orders() print(orders)

Can anyone please tell me how I can fix this issue?

tradingwithme commented 1 year ago

It seems that I am facing a conundrum: Is there anyone out there who can shed some light on this vexing issue? I am trying to resolve the verify picture verification, but alas, my attempts with the email address have been fruitless. Instead, I have been directed to use my phone number, yet every time I try, I am met with a frustrating error message on the Jupyter terminal. Can anyone help me navigate and find a solution to this problem?

image

image

tedchou12 commented 1 year ago

Would this work? https://github.com/tedchou12/webull/wiki/Workaround-for-Login

To be honest, going through the security is too much hassle, I use the workaround method myself as well.

ICANTFINDAUSERNAMEATALL commented 1 year ago

Personally, I found that using that using the workaround isn't the best for me. I found that as long as you save the did.bin file, you should be good. If you don't have the did.bin file(that means you started using this package after webull added a verification), you can always find your did by using the workaround, then the did from the headers section(in request headers) image

then you can just copy your did into your actual code and then do something like this:

` wb = webull()

wb._did = "whatever the did is should be tons of random letters an numbers but should be in hex"

wb.login(email, pw)

wb.get_trade_token(code) ` this will set your code as your "browser" and then you can do whatever you want from there

tedchou12 commented 1 year ago

Thank you for the add on

MachineITSvcs commented 1 year ago

Verification code is also failing to send on https://app.webull.com using web browser. When attempting to send via API, I also get the "AccessToken is expire" message. Not sure how to include an access token when I'm trying trying to send the verification code to complete login to get the token. Could it be an issue on Webull's end, or fundamental change in their API?

ICANTFINDAUSERNAMEATALL commented 1 year ago

this is because you already logged in. go to https://app.webull.com/ and then go to inspect page. refresh, and you should see tons of packages. just click on any request that has a type called "fetch". there should be a did header inside request headers.

then you can manually set your did in your code. Example:

wb = webull()

wb._did = "whatever the did is should be tons of random letters an numbers but should be in hex"

wb.login(email, pw)

print(wb.get_trade_token(code)) # prints true if login is successful

# you can do whatever you want now, your login should work

lmk if it still doesn't work.

I submitted a pull request to add a function which allows you to manually set your code's did. Here's the link: https://github.com/tedchou12/webull/pull/371/commits/c479478fbea21d87cc53e764690facd43d69910b you can try to just copy the code over and it should set your did.bin file as your did.

MachineITSvcs commented 1 year ago

I am not already logged in via the web browser. The popup for login shows up, and after entering username and password, I get a second popup that loads indefinitely. If I use developer tools to delete the element (second popup) I see a screen below prompting for the verification code "sent to: undefined" - no verification code was received either.

I have also tried the suggested "did" method (I was able to successfully authenticate last month, and still had the did.bin). However, with that method, I still receive the error message "You are using an outdated version of Webull Desktop. Please update your application by visiting www.webull.com/introduce." when attempting to login. I also tried using did from web browser fetch as suggested with same result. Not sure if I need to be updating any other the header information or not.

ICANTFINDAUSERNAMEATALL commented 1 year ago

try to uninstall some extensions you might have(its probably an ad blocker). What doesn't get "loaded" is a verification, which you will need to complete before you can find your did.

You'll also need to update this package. webull changed their endpoints for parts of their api.

MachineITSvcs commented 1 year ago

I updated the package and had some progress. Thank you for that suggestion. Now it's failing image verification though and I can't seem to get it to use the security questions instead.

ICANTFINDAUSERNAMEATALL commented 1 year ago

this is because you already logged in. go to https://app.webull.com/ and then go to inspect page. refresh, and you should see tons of packages. just click on any request that has a type called "fetch". there should be a did header inside request headers.

then you can manually set your did in your code. Example:

wb = webull()

wb._did = "whatever the did is should be tons of random letters an numbers but should be in hex"

wb.login(email, pw)

print(wb.get_trade_token(code)) # prints true if login is successful

# you can do whatever you want now, your login should work

lmk if it still doesn't work.

I submitted a pull request to add a function which allows you to manually set your code's did. Here's the link: c479478 you can try to just copy the code over and it should set your did.bin file as your did.

just use this. its much easier to verify a did from chrome, then take the did and put it into the api. once you login from the https://app.webull.com/ and you can see you account, then the did is verified. after that, just set the did before you login and it should fix the login issue.

ICANTFINDAUSERNAMEATALL commented 1 year ago

Personally, I found that using that using the workaround isn't the best for me. I found that as long as you save the did.bin file, you should be good. If you don't have the did.bin file(that means you started using this package after webull added a verification), you can always find your did by using the workaround, then the did from the headers section(in request headers) image

then you can just copy your did into your actual code and then do something like this:

` wb = webull()

wb._did = "whatever the did is should be tons of random letters an numbers but should be in hex"

wb.login(email, pw)

wb.get_trade_token(code) ` this will set your code as your "browser" and then you can do whatever you want from there

sorry, I meant this message

MachineITSvcs commented 1 year ago

I have tried this and am still unable to log in. I've copied the did from the web browser and even used part of the code from your commit today for setting a did to ensure the did file was updated as well, and I checked the headers to ensure the new did was being used, yet I still get the "Fail to verify image verification code." message when trying to use the login function.

As a side note, any way we could update the get_mfa function to not just return true, but also return response?

ICANTFINDAUSERNAMEATALL commented 1 year ago

You can just go into the package's code and manually modify it. If it says "Fail to verify image verification code." it most likely means that the did hasn't been verified yet. Print the login, if it is a long dictionary or json, then you should be good. Can you send a screenshot of your code and the response so that I can see what's going on?

MachineITSvcs commented 1 year ago

I am printing the login response. That is what's returning the image verification message. Can you please elaborate on what you mean by verified did? My web browser won't let me complete login (as mentioned previously). I only get so far as completing the image verification before getting that second popup that loads indefinitely, with the window behind it waiting for a verification code that was never sent. I suppose it could be my computer. I'll try a different one here shortly and follow up, but some of the resources are failing to load in the console and (connecting timing out) and even attempting to check them using an online status checker ( httpstatus.io) return a timeout error.

On Sun, Jan 1, 2023, 7:43 PM ICANTFINDAUSERNAMEATALL < @.***> wrote:

You can just go into the package's code and manually modify it. If it says "Fail to verify image verification code." it most likely means that the did hasn't been verified yet. Print the login, if it is a long dictionary or json, then you should be good. Can you send a screenshot of your code and the response so that I can see what's going on?

— Reply to this email directly, view it on GitHub https://github.com/tedchou12/webull/issues/366#issuecomment-1368581646, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD7WLROOKEPDKMWY6N2S5D3WQIQDLANCNFSM6AAAAAATGOZ5MI . You are receiving this because you commented.Message ID: @.***>

MachineITSvcs commented 1 year ago

I just tried from a different computer, a different browser, and even from my phone (using mobile data), and couldn't complete the login from the website at all. So it doesn't seem to be related to any extensions or internet connection.

If login isn't necessary to verify did, please let me know. I'm copying it directly from the developer tools fetch type request "all"

On Sun, Jan 1, 2023, 7:55 PM Collin Machine @.***> wrote:

I am printing the login response. That is what's returning the image verification message. Can you please elaborate on what you mean by verified did? My web browser won't let me complete login (as mentioned previously). I only get so far as completing the image verification before getting that second popup that loads indefinitely, with the window behind it waiting for a verification code that was never sent. I suppose it could be my computer. I'll try a different one here shortly and follow up, but some of the resources are failing to load in the console and (connecting timing out) and even attempting to check them using an online status checker ( httpstatus.io) return a timeout error.

On Sun, Jan 1, 2023, 7:43 PM ICANTFINDAUSERNAMEATALL < @.***> wrote:

You can just go into the package's code and manually modify it. If it says "Fail to verify image verification code." it most likely means that the did hasn't been verified yet. Print the login, if it is a long dictionary or json, then you should be good. Can you send a screenshot of your code and the response so that I can see what's going on?

— Reply to this email directly, view it on GitHub https://github.com/tedchou12/webull/issues/366#issuecomment-1368581646, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD7WLROOKEPDKMWY6N2S5D3WQIQDLANCNFSM6AAAAAATGOZ5MI . You are receiving this because you commented.Message ID: @.***>

ICANTFINDAUSERNAMEATALL commented 1 year ago

You don't want to verify the did from the console. Its really weird and they added updates so fast so its much easier to manually get the did.

What I mean by verified did is that the "device id" that you send to webull must be "verified" in their server that it is you so that webull will allow you to just login without image verification the next time. Once you verify the did, then webull's servers will "know" that the did in the request is from a "you".

If you can't complete the login, you can't verify your did since I don't know a workaround for the image verification thing.

You should probably try contacting webull about the login since I can't really help you much if you can't login to webull.

MachineITSvcs commented 1 year ago

Update: I was able to log in from my second Webull account, which has a phone number added for multi-factor authentication, so it was able to send me a code to my phone number. It's odd the other account won't send a code to my email.

MachineITSvcs commented 1 year ago

Unfortunately I wasn't then able to use the same did with the other account without the same issue as before... Looks like I'll have to contact Webull like you said. Might be an issue with my account's MFA.

MachineITSvcs commented 1 year ago

Alright, so by adding a phone number to the account I was able to get it to work. Thanks again for your help!

manojjenago commented 1 year ago

I am trying to login. But it says access token is expired even though I gave the correct MFA.

{'msg': 'AccessToken is expire', 'traceId': '431d6e8ff1b743628209e838bc3dd94a', 'code': 'auth.token.expire'}

My code is :

from webull import paper_webull

wb = paper_webull()

wb.get_mfa('') mfa_code = input("MFA Code: ") print(wb.get_security('')) answer = input("Security Question Answer: ") question_id = input("Question : ")

wb.login('', '', '', mfa_code, question_id, answer)

print(wb.get_trade_token('')) wb.place_order(stock='SNAP', price=50.0, quant=1) orders = wb.get_current_orders() print(orders)

Can anyone please tell me how I can fix this issue?

Hi Sabujhh,

I am facing the same issue as you mentioened. {'msg': 'AccessToken is expire', 'traceId': '2277d0a482d44cadb90666706ac6ef02', 'code': 'auth.token.expire'}. Also I did not see the account or response in the network tab. Please let me know how did you solve it. I will try the other option that is mentioned with did .

Thanks,

ICANTFINDAUSERNAMEATALL commented 1 year ago

@manojjenago Try not using the workaround. Try to just use the login function: wb.login(email, pw).

manojjenago commented 1 year ago

@manojjenago Try not using the workaround. Try to just use the login function: wb.login(email, pw).

Thanks, I will give a try. wb.get_trade_token(code) I am getting error that code is not defined. Do I need to set anything or need to assign it ?

Thanks,

MachineITSvcs commented 1 year ago

code should be replaced with your trade pin code. Usually six digits.

On Tue, Jan 3, 2023, 8:26 PM manojjenago @.***> wrote:

@manojjenago https://github.com/manojjenago Try not using the workaround. Try to just use the login function: wb.login(email, pw).

Thanks, I will give a try. wb.get_trade_token(code) I am getting error that code is not defined. Do I need to set anything or need to assign it ?

Thanks,

— Reply to this email directly, view it on GitHub https://github.com/tedchou12/webull/issues/366#issuecomment-1370389976, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD7WLRJQZBMX6DVUHF23CATWQTGTNANCNFSM6AAAAAATGOZ5MI . You are receiving this because you commented.Message ID: @.***>

manojjenago commented 1 year ago

code should be replaced with your trade pin code. Usually six digits. On Tue, Jan 3, 2023, 8:26 PM manojjenago @.> wrote: @manojjenago https://github.com/manojjenago Try not using the workaround. Try to just use the login function: wb.login(email, pw). Thanks, I will give a try. wb.get_trade_token(code) I am getting error that code is not defined. Do I need to set anything or need to assign it ? Thanks, — Reply to this email directly, view it on GitHub <#366 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD7WLRJQZBMX6DVUHF23CATWQTGTNANCNFSM6AAAAAATGOZ5MI . You are receiving this because you commented.Message ID: @.>

Thanks for quick response. I will update code with trading code. Thanks,

nackster commented 1 year ago

I'm getting "Fail to verify image verification code" error returned when logging in with the login(username, password) function. Has anybody else been able to find a solution to this? In my particular situation, I'm not able to acquire the did. Is there a workaround?

MachineITSvcs commented 1 year ago

So what worked for me was using the did method.

I used a web browser to go to app.webull.com and then used the web developer tools to get the did. Then I performed the login, via the web browser, to my account and verified the image.

Then I used that same did from the browser to authenticate using just the login() method, followed by get_trade_token(), without mfa.

manojjenago commented 1 year ago

code should be replaced with your trade pin code. Usually six digits. On Tue, Jan 3, 2023, 8:26 PM manojjenago @._> wrote: @manojjenago https://github.com/manojjenago Try not using the workaround. Try to just use the login function: wb.login(email, pw). Thanks, I will give a try. wb.get_tradetoken(code) I am getting error that code is not defined. Do I need to set anything or need to assign it ? Thanks, — Reply to this email directly, view it on GitHub <#366 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD7WLRJQZBMX6DVUHF23CATWQTGTNANCNFSM6AAAAAATGOZ5MI . You are receiving this because you commented.Message ID: @_._>

Thanks for quick response. I will update code with trading code. Thanks,

Hi ,

The method worked for me with log in ` wb = webull() wb._did = "" ( https://github.com/tedchou12/webull/issues/366#issuecomment-1368542473)

wb.login(email, pw) wb.get_trade_token(code) ` // The Code is the trading PIN

Any one is trying to use the Workaround -

I found that now in network tab - it is under V2 (not account) any more. Check for V2 messages with below {"extInfo": {"userPwdFlag": "1", "equipmentCheck": "success"}, "accessToken": .............................

You can add that to the credentials json file. But as suggested, please try to avoid that and use the login method with did file. It is easy and works fine.

johnathanhawn commented 1 year ago

any updates, on how to get login to work, also it seems like there are steps to make this work and I never seem to get an access token that works, but im not sure im doing it correctly.

altair0622 commented 1 year ago

this is because you already logged in. go to https://app.webull.com/ and then go to inspect page. refresh, and you should see tons of packages. just click on any request that has a type called "fetch". there should be a did header inside request headers.

then you can manually set your did in your code. Example:

wb = webull()

wb._did = "whatever the did is should be tons of random letters an numbers but should be in hex"

wb.login(email, pw)

print(wb.get_trade_token(code)) # prints true if login is successful

# you can do whatever you want now, your login should work

lmk if it still doesn't work.

I submitted a pull request to add a function which allows you to manually set your code's did. Here's the link: c479478 you can try to just copy the code over and it should set your did.bin file as your did.

Do we still need those jobs even though we can get the value of did using wb._did? If then, could you please explain the steps we need to follow? Otherwise, could you tell me how to avoid the message ('msg': 'Fail to verify image verification', 'code' : 'user.check.slider.pic.fail'). Thanks for your helps!

ICANTFINDAUSERNAMEATALL commented 1 year ago

Here: https://github.com/tedchou12/webull/issues/366#issuecomment-1368542357

Follow those instructions to generate a image verified did and then you can use that to bypass the image verification.