Unable to login to IBKR using QuantRocket

I have 2FA enabled on my IBKR account. When I try to connect QuantRocket to IBKR using the jupyter notebook, it always fails.

from quantrocket.ibg import set_credentials
set_credentials("ibg1", username="username", trading_mode="live or paper")

When I execute the above, if IB gateway is running, I get an error:

{'status': 'error', 'msg': 'please stop IB Gateway before setting credentials (current status is: error)'})

When I stop the IB gateway, the cell hangs for a while, I receive a 2FA notification and then it fails.

For the live account, I am able to bypass this problem by directly using IB Gateway GUI to connect to IBKR. For the paper account, I am not able to use the same way. I see the error in the screenshot, when I try to login to the paper account on IB Gateway GUI.

Need help to resolve the login issue with the paper account (more important at the moment) and live account.

The error message in the screenshot means that there are multiple paper account logins associated with your live account login. Because of this, you can't access your paper account by entering your live account credentials and choosing paper trading (paper=True). Instead, to access the paper account, you must enter the paper account login credentials. You can find your paper account usernames by logging into IBKR Client Portal with your live account username and navigating to the settings page.

For the live account, can you be more specific about what happens after you receive the 2FA notification? The expected flow is that you click the notification on your phone, your phone indicates that the authorization succeeded, and IB Gateway will successfully be logged in. A successful login can be confirmed by opening the IB Gateway GUI or by running quantrocket.ibg.list_gateway_statuses and seeing a status of "running".

Perfect, i got the paper account and able to do paper trading!