tedchou12 / webull

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

Some funcs needs access token while it's previously not required #355

Open AdriandLiu opened 1 year ago

AdriandLiu commented 1 year ago

Hi, I'm trying to use _get_mfa_ func to get my mfa code sending to my email. It however raises the following error msg to me {'msg': 'AccessToken is expire', 'traceId': 'e85d8088eb33417d9db2e2d467632f99', 'code': 'auth.token.expire'}

I also tried _get_security, next_security_, both returned same error as above. All of those funcs does not require any access token before, does Webull change their endpoint again or I missed anything? Any opinions are greatly appreciated!

AdriandLiu commented 1 year ago

Okay I think there is an alternative.

First, Webull changed their MFA endpoint again. The latest one is https://u1suser.webullfintech.com/api/user/v1/verificationCode/send/v2 (still unsure about get_security and next_security)

However, if you call this endpoint even with correct payload, it will return you an image URl for image verification (in Postman). What I did to work this around is, recall the approach of how to get the verified device in this thread https://github.com/tedchou12/webull/issues/353#issuecomment-1324429735, you don't have to use mfa when the device id is verified with image sliding, so it basically ends up like webull.login(email, password)

instead of

webull.login(email, password, mfa_code...)

ICANTFINDAUSERNAMEATALL commented 1 year ago

I did the same thing. I think I mentioned it in the previous thread but as long as you have the device id file, you can login with just the webull.login() function without using any more verification. I just stopped using the accesstoken way and decided to use the way you just mentioned.

AdriandLiu commented 1 year ago

@ICANTFINDAUSERNAMEATALL access token seems working well in my case, is there any specific reason to switch?

ICANTFINDAUSERNAMEATALL commented 1 year ago

For me, using het access token thing gave the exact same message:

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

Some reason, I just decided to not use the access token and see if it would work and since then, just using: wb.login(my_email, my_pw) worked for me. Idk if this is just on my end or for everyone else.

Here is the timeline of how things happened:

  1. I logged in and got the device id files and saved the response
  2. I used the https://github.com/tedchou12/webull/wiki/Workaround-for-Login and it worked for a while
  3. I got the same error you got and tried reentering the mfa things(I just pretended that I haven't logged in before and try to reset things). From this, I got the same error, no matter what happened
  4. I randomly tried to use the simple wb.login(email, pw) with nothing else.
  5. After I switched back to the standard login, everything seems to be working just like before.

@AdriandLiu try to just use wb.login(email, pw). It fixed the problem for me so it might work for you.

AdriandLiu commented 1 year ago

@ICANTFINDAUSERNAMEATALL that makes sense to me and thanks a lot for the suggestion!

M1NL1TE commented 1 year ago

Okay I think there is an alternative.

First, Webull changed their MFA endpoint again. The latest one is https://u1suser.webullfintech.com/api/user/v1/verificationCode/send/v2 (still unsure about get_security and next_security)

However, if you call this endpoint even with correct payload, it will return you an image URl for image verification (in Postman). What I did to work this around is, recall the approach of how to get the verified device in this thread https://github.com/tedchou12/webull/issues/353#issuecomment-1324429735, you don't have to use mfa when the device id is verified with image sliding, so it basically ends up like

webull.login(email, password)

instead of

webull.login(email, password, mfa_code...)

Where in the code do you add the new endpoint? Do you replace it with something in the endpoints.py and the Webull.py? I tried using the regular wb.login(email, pw) but I still get the accesstoken error @AdriandLiu

ICANTFINDAUSERNAMEATALL commented 1 year ago

I think you can update it right here:

https://github.com/tedchou12/webull/blob/d3a8ee55cde2ee32716578401d082ea60cc1998d/webull/endpoints.py#L93C1-L93C1

I haven't used the api in a while so IDK if it still works or not

M1NL1TE commented 1 year ago

@ICANTFINDAUSERNAMEATALL

Sorry if it's an obvious answer but am I just changing the url for the self.base_user_url to https://u1suser.webullfintech.com/api/user/v1/verificationCode/send/v2 in the second screenshot?

image

image