Hi Team,
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 client_id and redirect_uri. Suppose you’ve registered your app with the redirect_uri as 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.
This 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 abc.com/upstox/home.
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."
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)
Hi Shanmu,
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.