tedchou12 / webull

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

Login Verification #388

Closed WisdomCreation closed 1 year ago

WisdomCreation commented 1 year ago

Hi, I'm getting error while login to my account, using Webull API,

res = wb.login(user_id , passw , "PythonTest" , mfa , ques_id , ques_ans) I'm using this line of code with everything correct details, I'm getting the response (erros) as,

{'msg': 'Fail to verify image verification code.',
 'traceId': 'cf7a1bd3959942358db2d14e58ab56cd',
 'code': 'user.check.slider.pic.fail'}

Please let me know where I'm not getting it, and how can I solve this issue, Thanks,

RealmX1 commented 1 year ago

Same problem... the API isn't made by Webull, nor is it currently well maintained. Webull probably added slider puzzle for checking bot after this api is last updated.

RealmX1 commented 1 year ago

https://github.com/tedchou12/webull/wiki/Workaround-for-Login-Method-2 I tried this method suggested by author but it didn't work.

aloy14 commented 1 year ago

https://github.com/tedchou12/webull/wiki/Workaround-for-Login-Method-2 I tried this method suggested by author but it didn't work.

me too tried and it does not work

kickshawprogrammer commented 1 year ago

I use the steps from Method 2 with the following CTraderBot class without issues.

from webull import webull, paper_webull
from _secrets import WEBULL_LOGIN_EMAIL, WEBULL_LOGIN_PWD, WEBULL_DEVICE_ID, \
                     WEBULL_TRADING_PIN, WEBULL_SECURITY_DID

class CTraderBot:
  def __init__(self, paper_trading: bool = False) -> None:
    self._webull = paper_webull() if (paper_trading) else webull()
    self._loggedin = False

  def login(self, use_workaround: bool = False) -> bool:
    wb = self._webull
    if (use_workaround):
      wb._set_did(WEBULL_SECURITY_DID)

    wb.login(username=WEBULL_LOGIN_EMAIL, password=WEBULL_LOGIN_PWD, device_name=WEBULL_DEVICE_ID)

    self._loggedin = wb.get_trade_token(WEBULL_TRADING_PIN)
    self._webull = wb

    return self._loggedin

def main():
  my_bot = CTraderBot(True)

  success = "Success!" if (my_bot.login()) else "Failed!"
  print(f"Logging into webull: {success}")

if __name__ == '__main__':
    main()

For me, the key was to make sure I was logged into webull in my browser first. Minimize the browser after getting the DID as described and then call the CTraderBot.login() passing True so that the DID file gets created. As I'm sure you can tell, the info in the _secrects.py contain all of the relevant Webull information within a file that gets .gitignore'd at check-ins.

Once my app connects to webull, then I can close the browser. Once connected in this way, the app will continue to work until you log out of the browser version. Closing the browser does not log me out - I'm sure somehow cookies are involved so if you don't allow cookies then it may be a problem.

I hope this helps,

DouGrimaldi commented 1 year ago

I use the steps from Method 2 with the following CTraderBot class without issues.

from webull import webull, paper_webull
from _secrets import WEBULL_LOGIN_EMAIL, WEBULL_LOGIN_PWD, WEBULL_DEVICE_ID, \
                     WEBULL_TRADING_PIN, WEBULL_SECURITY_DID

class CTraderBot:
  def __init__(self, paper_trading: bool = False) -> None:
    self._webull = paper_webull() if (paper_trading) else webull()
    self._loggedin = False

  def login(self, use_workaround: bool = False) -> bool:
    wb = self._webull
    if (use_workaround):
      wb._set_did(WEBULL_SECURITY_DID)

    wb.login(username=WEBULL_LOGIN_EMAIL, password=WEBULL_LOGIN_PWD, device_name=WEBULL_DEVICE_ID)

    self._loggedin = wb.get_trade_token(WEBULL_TRADING_PIN)
    self._webull = wb

    return self._loggedin

def main():
  my_bot = CTraderBot(True)

  success = "Success!" if (my_bot.login()) else "Failed!"
  print(f"Logging into webull: {success}")

if __name__ == '__main__':
    main()

For me, the key was to make sure I was logged into webull in my browser first. Minimize the browser after getting the DID as described and then call the CTraderBot.login() passing True so that the DID file gets created. As I'm sure you can tell, the info in the _secrects.py contain all of the relevant Webull information within a file that gets .gitignore'd at check-ins.

Once my app connects to webull, then I can close the browser. Once connected in this way, the app will continue to work until you log out of the browser version. Closing the browser does not log me out - I'm sure somehow cookies are involved so if you don't allow cookies then it may be a problem.

I hope this helps,

I tried this but this still doesn't work for me, followed all your steps and my _secrets.py file has the correct information and I have my webull open in the browser but it's still saying "Logging into webull: Failed! " any help?

kickshawprogrammer commented 1 year ago

I don't know. All I can think is that you didn't get the correct DID. Are you sure that you followed the directions from here? Remember that the instructions say to refresh the page before getting your DID.

And for clarity, the contents of my __secrets.py_ are as follows:

WEBULL_LOGIN_EMAIL: str = "xxxxxxxxxxxxxxxxxxxxxx"
WEBULL_LOGIN_PWD: str = "xxxxxxxxxxxx"
WEBULL_TRADING_PIN: str = "xxxxxx"
WEBULL_DEVICE_ID: str = "Trader-Bot"
WEBULL_SECURITY_DID: str = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

EDIT: Oh, and call CTraderBot.login(True) to save the DID to the .bin file for the first call. Then you can drop the True in further calls

DouGrimaldi commented 1 year ago

I don't know. All I can think is that you didn't get the correct DID. Are you sure that you followed the directions from here? Remember that the instructions say to refresh the page before getting your DID.

And for clarity, the contents of my __secrets.py_ are as follows:

WEBULL_LOGIN_EMAIL: str = "xxxxxxxxxxxxxxxxxxxxxx"
WEBULL_LOGIN_PWD: str = "xxxxxxxxxxxx"
WEBULL_TRADING_PIN: str = "xxxxxx"
WEBULL_DEVICE_ID: str = "Trader-Bot"
WEBULL_SECURITY_DID: str = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

EDIT: Oh, and call CTraderBot.login(True) to save the DID to the .bin file for the first call. Then you can drop the True in further calls

i set the .login(True) but now i'm getting AttributeError: 'paper_webull' object has no attribute '_set_did'

i'm new to programming so sorry i'm missing something obvious. Also yes, I'm positive I got the correct DID and followed those steps.

DouGrimaldi commented 1 year ago

I don't know. All I can think is that you didn't get the correct DID. Are you sure that you followed the directions from here? Remember that the instructions say to refresh the page before getting your DID.

And for clarity, the contents of my __secrets.py_ are as follows:

WEBULL_LOGIN_EMAIL: str = "xxxxxxxxxxxxxxxxxxxxxx"
WEBULL_LOGIN_PWD: str = "xxxxxxxxxxxx"
WEBULL_TRADING_PIN: str = "xxxxxx"
WEBULL_DEVICE_ID: str = "Trader-Bot"
WEBULL_SECURITY_DID: str = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

EDIT: Oh, and call CTraderBot.login(True) to save the DID to the .bin file for the first call. Then you can drop the True in further calls

okay I figured it out, my mistake, your code works perfectly and logs me in-- i just for some reason had a really old version of the API installed. Thanks!