Error while getting Access Token Request

import os
import requests
from dotenv import load_dotenv

load_dotenv()

UPSTOX_API_KEY = os.getenv(“UPSTOX_API_KEY”)
UPSTOX_API_SECRET = os.getenv(“UPSTOX_API_SECRET”)

if not UPSTOX_API_KEY:
raise ValueError(“Missing UPSTOX_API_KEY. Set it in the environment variables.”)

url = f"https://api.upstox.com/v3/login/auth/token/request/{UPSTOX_API_KEY}"

headers = {
“Accept”: “application/json”,
#“Content-Type”: “application/json”,
}

payload = {
“client_secret”: UPSTOX_API_SECRET
}

response = requests.post(url, headers=headers, data=payload)

print(response.status_code)
try:
print(response.json())
except Exception as e:
print(“Error parsing JSON response:”, e)

error message:
400
{‘status’: ‘error’, ‘errors’: [{‘errorCode’: ‘UDAPI10000’, ‘message’: ‘This request is not supported by Upstox API’, ‘propertyPath’: None, ‘invalidValue’: None, ‘error_code’: ‘UDAPI10000’, ‘property_path’: None, ‘invalid_value’: None}]}

whats wrong in this code?

Hi @the_singh

It looks like you are using an invalid URL path. Please refer to the API documentation here: Authentication Guide for the correct login procedure.

Additionally, you can check out the example code for reference: Example Code.

Thanks!