-
Notifications
You must be signed in to change notification settings - Fork 2
Authentication
Groww MCP supports 3 authentication methods. Choose the one that fits your workflow.
Fully automated. No daily manual steps. The server generates fresh access tokens automatically on every startup.
- You provide a TOTP key (JWT) and TOTP secret (base32 string)
- On startup, the server generates a 6-digit TOTP code using the secret
- It sends the code + key to Groww's token endpoint
- Groww returns a fresh access token valid until 6:00 AM IST
- The server auto-refreshes the token if it expires during the session
- Log in to groww.in
- Go to Profile β Settings β Trading APIs
- Click the "Generate API key" dropdown β "Generate TOTP token"
- You'll receive two values:
| What you see | What to save as |
|---|---|
TOTP Token β a long JWT string starting with eyJ...
|
GROWW_TOTP_KEY |
TOTP QR Secret β a short base32 string like UG3X...
|
GROWW_TOTP_SECRET |
- Add to your
.env:
GROWW_TOTP_KEY=eyJraWQi...your_totp_jwt_key
GROWW_TOTP_SECRET=UG3XTATB22XLH5SGGLHHV736PEOYUZSBThat's it. Never visit the website again for auth.
- Uses the ROTP gem for TOTP code generation
- Token endpoint:
POST https://api.groww.in/v1/token/api/access - Payload:
{ key: TOTP_KEY, key_type: "totp", question_id: "TOTP", answer: "6-digit-code" } - Access token expires daily at 6:00 AM IST
- Server tracks expiry and refreshes automatically (5-minute buffer)
Requires daily approval on the Groww website before the server can generate tokens.
- Go to groww.in β Settings β Trading APIs
- Click "Generate API key" β Create a key
- Copy the API Key and API Secret
- Add to
.env:
GROWW_API_KEY=eyJraWQi...your_api_key
GROWW_API_SECRET=your_api_secret- Every day: Visit the Trading APIs page and click "Approve" next to your key
- Uses SHA256 checksum:
SHA256(api_secret + timestamp_ms) - Token endpoint:
POST https://api.groww.in/v1/token/api/access - Payload:
{ key: API_KEY, key_type: "approval", checksum: SHA256_HEX, timestamp: epoch_ms }
The API secret may contain special characters (%, (, )) that break in shell environments. The Ruby implementation handles these correctly β no escaping needed.
For quick testing. Token expires daily at 6:00 AM IST.
- Go to groww.in β Settings β Trading APIs
- Click "Generate API key" dropdown β "Generate Access Token"
- Copy the token
- Add to
.env:
GROWW_ACCESS_TOKEN=eyJraWQi...your_access_tokenYou'll need to regenerate this token every day before 6:00 AM IST.
If multiple credentials are present, the server uses this priority:
-
TOTP (if
GROWW_TOTP_KEY+GROWW_TOTP_SECRETare set) -
Approval (if
GROWW_API_KEY+GROWW_API_SECRETare set) -
Manual (if
GROWW_ACCESS_TOKENis set)
Groww requires a static IP for order placement (SEBI compliance). Register your IP at:
Groww App β Settings β Trading APIs β Add Static IP
Read-only operations (holdings, positions, order list) work without a static IP.
| Issue | Cause | Fix |
|---|---|---|
401 Unauthorized |
Token expired | Restart server (TOTP auto-refreshes) or regenerate manual token |
403 Forbidden on market data |
No subscription | Subscribe to Groww Live Data (βΉ499/mo) |
Invalid credentials |
Wrong TOTP secret | Regenerate TOTP token on Groww website |
| Token works but orders fail | No static IP | Register your IP in Groww Trading APIs settings |
Built by Jai Rajput | MIT License | Report an Issue
Setup
Reference
Community
Links