Trying to use the API V2 Python. Still getting the same error
pi_instance = upstox_client.LoginApi()
api_version = ‘v2’ # str | API Version Header
code = CODE # str | (optional)
client_id = CLIENTID # str | (optional)
client_secret = CLIENT_SECRET # str | (optional)
redirect_uri = REDIRECTURL # str | (optional)
grant_type = GRANTTYPE # str | (optional)
try:
# Get token API
api_response = api_instance.token(api_version, code=code, client_id=client_id, client_secret=client_secret, redirect_uri=redirect_uri, grant_type=grant_type)
pprint(api_response)
except ApiException as e:
print(“Exception when calling LoginApi->token: %s\n” % e)
Error
Exception when calling LoginApi->token: (401)
Reason: Unauthorized
HTTP response headers: HTTPHeaderDict({‘Date’: ‘Sat, 22 Jul 2023 11:06:58 GMT’, ‘Content-Type’: ‘application/json’, ‘Transfer-Encoding’: ‘chunked’, ‘Connection’: ‘keep-alive’, ‘Vary’: ‘Origin, Access-Control-Request-Method, Access-Control-Request-Headers’, ‘message’: ‘request failed’, ‘requestId’: ‘398e811b-ac60-49e3-be47-b16d8a7d5f9d’, ‘X-Content-Type-Options’: ‘nosniff’, ‘X-XSS-Protection’: ‘1; mode=block’, ‘Cache-Control’: ‘no-cache, no-store, max-age=0, must-revalidate’, ‘Pragma’: ‘no-cache’, ‘Expires’: ‘0’, ‘Strict-Transport-Security’: ‘max-age=0; includeSubDomains’, ‘X-Frame-Options’: ‘DENY’, ‘CF-Cache-Status’: ‘DYNAMIC’, ‘Set-Cookie’: ‘_cfuvid=SCig6U0dvIycI_TKtnFHIEoTkkdRtFeLguXzeDFR9xI-1690024018785-0-604800000; path=/; domain=.upstox.com; HttpOnly; Secure; SameSite=None’, ‘Server’: ‘cloudflare’, ‘CF-RAY’: ‘7eab37a50e8c3c06-BLR’})
HTTP response body: b’{“status”:“error”,“errors”:[{“errorCode”:“UDAPI100057”,“message”:“Invalid Auth code”,“propertyPath”:null,“invalidValue”:null,“error_code”:“UDAPI100057”,“property_path”:null,“invalid_value”:null}]}’
{‘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}]}