Issue with redirect url local

I am using the current code that is copied from the example to get the initial code.

url = "https://api.upstox.com/v2/login/authorization/dialog"

payload={}
headers = {}

payload={
    "client_id":UPSTOX_KEY,
    "redirect_uri":"http://localhost:5000/upstox_redirect",
    "response_type":"code"
}

response = requests.request("GET", url, headers=headers, params=payload)

The redirect uri in the return link is being replaced with

https://login.upstox.com/login/v2/oauth/authorize?redirect_uri=https://api-v2.upstox.com/login/authorization/redirect&response_type=code

and not to the localhost:5000 url as mentioned. how do i get past this?

{'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}]}

Hi @ABHINAV_7755754
This step requires execution within a web browser. Using the API for this purpose will redirect you to the Upstox login page in a browser, where you must input your login credentials. For more comprehensive information, please refer to the following documentation: Authentication | Upstox Developer API.

Thank you!

yes after entering the mobile otp and pin. i get that error mentioned

question here is shouldn’t the redirect uri be the one that I mentioned instead of the api-v2.upstox?
it should be localhost:5000/upstox_redirect right?

@ABHINAV_7755754 can you check what is the redirect url you have set for your api app in my profile section, and confirm the same here.

its the same as the one here. it wasn’t giving me the url to enter credentials otherwise.

You should be redirected to your local URL. Are you using a third-party-created app, or did you create this app yourself?

My code. On local machine.

Can you share your 6 digit user id so we can investigate this further?

sent you a direct message

1 Like

please update when you find something. Thanks

found the issue. if we do a requests.get on the url then it gives a default redirect uri. instead if we create a url with those params using urlencode then we get the correct result. Now i m able to get the access token.

New problem with websockets.

PS F:\programming\tb2025\v3> python .\websocket_client.py
{'status': 'success', 'data': {'authorizedRedirectUri': 'wss://wsfeeder-api.upstox.com/market-data-feeder/v3/upstox-developer-api/feeds?requestId=b35e8a06-92fa-4ee0-843a-a4ad06c80754&code=x2Ba0-912af0bf-75db-41cb-a6b7-f3eae627f510', 'authorized_redirect_uri': 'wss://wsfeeder-api.upstox.com/market-data-feeder/v3/upstox-developer-api/feeds?requestId=b35e8a06-92fa-4ee0-843a-a4ad06c80754&code=x2Ba0-912af0bf-75db-41cb-a6b7-f3eae627f510'}}
Connection established
Traceback (most recent call last):
  File "F:\programming\tb2025\v3\websocket_client.py", line 75, in <module>
    asyncio.run(fetch_market_data())
  File "C:\Users\macab\.pyenv\pyenv-win\versions\3.12.7\Lib\asyncio\runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "C:\Users\macab\.pyenv\pyenv-win\versions\3.12.7\Lib\asyncio\runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\macab\.pyenv\pyenv-win\versions\3.12.7\Lib\asyncio\base_events.py", line 687, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "F:\programming\tb2025\v3\websocket_client.py", line 65, in fetch_market_data
    decoded_data = decode_protobuf(message)
                   ^^^^^^^^^^^^^^^^^^^^^^^^
  File "F:\programming\tb2025\v3\websocket_client.py", line 26, in decode_protobuf
    feed_response = pb.FeedResponse()
                    ^^^^^^^^^^^^^^^
AttributeError: module 'MarketDataFeedV3_pb2' has no attribute 'FeedResponse'


this is the current file structure. the pb2 and proto are in the same file. I even compiled the proto to get the py file again.

Downloaded those files again and compiled proto it wokred now.