• Recent
  • Categories
  • 0 Unread 0
  • Popular
  • Tags
  • More
    • Guidelines
    • Disclaimer
  • Users
Skins
  • Light
  • Default
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Quartz
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Slate
  • Solar
  • Superhero
  • Vapor
Collapse
Definedge Forum Logo

Issue with Definedge API – Unexpected Behavior / Error

Scheduled Pinned Locked Moved Ask Definedge Team (Subject related)
1 Posts 1 Posters 16 Views
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Deborah Graves
    wrote on last edited by
    #1

    Hello,
    I’ve been integrating the Definedge API into a Python trading bot and running into an authentication issue. I’m able to successfully authenticate and obtain an access token using my client_id and client_secret. However, after about 5 minutes, the token stops working, and every request starts returning this error:

    {
      "status": "error",
      "message": "Invalid or expired access token"
    }
    

    According to the docs, the token should be valid for at least 30 minutes.

    Code Sample:

    import requests
    
    BASE_URL = "https://api.definedgesecurities.com"
    
    login_payload = {
        "client_id": "my_client_id",
        "client_secret": "my_secret",
        "grant_type": "client_credentials"
    }
    
    token_res = requests.post(f"{BASE_URL}/auth/token", data=login_payload)
    token = token_res.json().get("access_token")
    
    headers = {"Authorization": f"Bearer {token}"}
    r = requests.get(f"{BASE_URL}/market/quotes?symbol=NIFTY", headers=headers)
    print(r.json())
    

    Has anyone else faced this premature token expiry issue? Do I need to explicitly refresh the token with another API call, or is there a configuration I might be missing on the Definedge side?

    1 Reply Last reply
    0


Recent Posts

  • D
    Issue with Definedge API – Unexpected Behavior / Error
  • D
    Issue with Definedge API – Unexpected Behavior / Error
  • Y
    Momentify logo disappeared in Portfolio
  • G
    Suggestion
  • R
    Repeated display of warning message regarding F&O Trades
  • Login

  • Login or register to search.
  • Blog
  • Youtube Videos
  • Refresh
  • First post
    Last post
0
  • Recent
  • Categories
  • Unread 0
  • Popular
  • Tags
  • More
    • Guidelines
    • Disclaimer
  • Users
  • Login

  • Login or register to search.
  • Blog
  • Youtube Videos
  • Refresh