I plan to develop a hobby app. And i intend to use a FE and a BE.
The documentation suggests to redirect to BE after providing OTP.
So the FE would be redirecting to upstox login page in browser. The user would login there.
Post successful login, the browser redirects to desired URL with a “code” as a parameter.
The documentation suggests this code to be sent to BE and later use it to generate the token.
But i am confused how would having the BE api in redirect help me get back to FE in browser.
Or is some other flow to be taken ? Or should the redirect be to FE only.
Certainly! Here’s a precise response to explain the ideal login process:
"When you implement the login flow for your app, start by setting up a landing page, for example,
abc.com/upstox. When a user clicks the login button on this page, initiate a login request with your
redirect_uri. Suppose you’ve registered your app with the
abc.com/upstox/redirect. After the user completes the authentication flow on Upstox, they will be redirected to
abc.com/upstox/redirect, along with an authentication code.
redirect_uri should be an API endpoint on your backend. When this endpoint receives the auth code, it should make a call to generate the access token. Once the access token is successfully generated, your backend can either render the Upstox home page view directly or redirect the user to another page, like
It’s important to understand that the entire process, from the user hitting the login button to landing on
abc.com/upstox/redirect, involves HTTP 302 redirects managed by Upstox. This means the browser will automatically follow these redirects based on the responses from Upstox. Your backend plays a crucial role in handling the auth code, generating the access token, and rendering the appropriate view to complete the whole auth flow."
Let me know if that makes sense.
Thank You Shanmu,
I am relatively new to api development, and was not exactly aware how a http 302 redirect works.
The answer that you gave makes a lot of sense now.
Thank you for replying so swiftly.
I have a fait idea on how to proceed with the development.
I had one more small query. For making the historical data query, I tried with the newer API (https://api.upstox.com/v2), but it throws some error. And when tried same with older API (api-v2.upstox.com), it does seem to work. Do you guys plan to update this later. If yes will the support for older one be removed ?
(Attached ss for same)
The new endpoint includes all APIs.
I’ve successfully tested accessing https://api.upstox.com/v2/historical-candle/NSE_EQ|INE467B01029/30minute/2023-12-11/2023-12-04 and everything seems to be working correctly on my end.
Could you give it a try and confirm if it’s functioning properly for you as well?
I was not working in postman, but was giving a response in browser.
So i tried this in postman with ‘%7C’ instead of ‘|’, and it seemed to work. Maybe some issue in postman in trying to process the ‘|’ pipe symbol. (NSE_EQ%7CINE467B01029)
But it works now.
Thank you for helping me out with the issues.
Happy to hear that your issue has been resolved and is now functioning properly.