• 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
D

Deborah Graves

About
Topics
2
Replies
2
Groups
0
Followers
0
Following
0

All Replies

Recent Best Controversial

    Issue with Definedge API – Unexpected Behavior / Error
  • D Deborah Graves

    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?


  • Issue with Definedge API – Unexpected Behavior / Error
  • D Deborah Graves

    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 / 1
  • 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