Authentication is the first bottleneck in every trading automation stack.
This guide explains:
- Common broker auth models
- Why auth design directly affects automation reliability
- How Nubra's phone + OTP/TOTP model enables true automation
- A practical
AutoLoginClient.pystyle implementation
Authentication Flow#
Traditional Broker Authentication#
<img src="/products/api/content/blogs/automated-authentication/assets/BrokerLoginFlowchart.png" class="auth-image" alt="Broker login flowchart"/>
<ul class="auth-points">
<li>Multiple redirect steps and browser-based login</li>
<li>Captcha and manual approvals add friction</li>
<li>Not suitable for automated or server-based execution</li>
</ul>
Nubra Authentication#
<img src="/products/api/content/blogs/automated-authentication/assets/NubraLoginFlowchart.png" class="auth-image" alt="Nubra login flowchart"/>
<ul class="auth-points">
<li>Single streamlined flow managed by the Nubra SDK</li>
<li>Works reliably across servers, cloud, CI/CD, and headless environments</li>
<li>Designed for full automation and robust algo-trading setups</li>
</ul>
Why Authentication Design Matters#
You can have a perfect strategy and still fail in production if auth is fragile.
In real systems, auth affects:
- Startup stability before market open
- Session renewal behavior during trading hours
- Recovery after restarts or deploys
- Multi-account orchestration at scale
So auth is not just security, it is execution infrastructure.
OAuth vs Phone + OTP/TOTP#
Many brokers use OAuth-style browser flows:
- Redirect to login page
- Manual consent or one-time callback handling
- Token management and refresh logic
This works, but for many automation pipelines it adds operational complexity.
At Nubra, tech and ease go together.
We chose phone + OTP/TOTP authentication so fully automated login flows can be built reliably in code.
Why Nubra's Model Is Automation-Friendly#
With phone + OTP/TOTP:
- Login can be orchestrated at runtime
- The flow is scriptable for scheduled startup
- You can avoid browser-driven manual intervention
- Infra remains simple for single or multi-strategy deployments
This is what we mean by true automation: your auth layer can run as part of your system, not outside it.
Prerequisites#
Before running automated login:
- Python 3.10+ installed
nubra-python-sdkinstalledpyotpinstalled- Nubra account phone number and MPIN
- TOTP secret configured securely
Install dependency:
pip install pyotpAutomated Login Example (AutoLoginClient.py)#
The following pattern enables TOTP-based automated authentication with Nubra SDK.
import pyotp
from contextlib import contextmanager
from nubra_python_sdk.start_sdk import InitNubraSdk, NubraEnv
# =====================================================
# CONFIG
# =====================================================
ENV = NubraEnv.PROD
PHONE = "your phone no"
MPIN = "your mpin"
TOTP_SECRET = "your secret"
def init_nubra_with_totp():
totp = pyotp.TOTP(TOTP_SECRET)
@contextmanager
def auto_login_input(phone, otp, mpin):
import builtins
original_input = builtins.input
def fake_input(prompt=""):
prompt = prompt.lower()
if "phone" in prompt:
return phone
if "otp" in prompt:
return otp
if "mpin" in prompt:
return mpin
return original_input(prompt)
builtins.input = fake_input
try:
yield
finally:
builtins.input = original_input
with auto_login_input(PHONE, totp.now(), MPIN):
return InitNubraSdk(ENV, totp_login=True)
nubra = init_nubra_with_totp()How This Works#
- Generates the current TOTP code using your secret.
- Intercepts SDK input prompts for phone, OTP, and MPIN.
- Injects credentials programmatically.
- Initializes Nubra SDK with
totp_login=True.
Net result: startup auth becomes deterministic and automation-ready.
Security Best Practices#
- Never hardcode secrets in committed files.
- Load
PHONE,MPIN, andTOTP_SECRETfrom environment variables or a secret manager. - Rotate credentials periodically.
- Run separate credentials for UAT and PROD.
Conclusion#
Broker auth is often treated as a small setup detail, but it determines whether a trading system is actually deployable.
With Nubra's phone + OTP/TOTP flow, authentication can be automated as part of your runtime stack, making algo systems easier to run, restart, and scale.
If you are building production trading automation, start by hardening auth first.
