Creating an App without Redirect URL

Why is it mandatory to have a Redirect URL while creating a App? My use case is to place an Order from a Java program when certain condition is met. I don’t have a domain or a fancy Mobile App.

A Redirect URL is required for the authentication process. After a successful authentication, the authentication API will redirect to the URL specified in the redirect_url parameter. This URL will contain the code necessary for generating the token as part of the request parameters.

For a better understanding, please refer to the Upstox Authentication and API Documentation.

You can also find implementation examples in the Example Codes section.

1 Like

I understand Redirect URL’s. Truth is my App is a simple Java program. What are my options to place an Order on Upstox?

How do Console Apps work who do not need a Redirect URL?

If you’re utilizing Java, you have two options for placing orders:

  1. Java HTTP requests
  2. Java SDK.

For specific instructions on placing orders, please consult the API Documentation | Place orders. Additionally, you can find example codes for both Java HTTP requests and the Java SDK here.

Thanks @Ketan : I understand using the HTTP request + the SDK part. However if I can’t create an App how will I get the Bearer token?

Below line from the example code shared by Upstox.
String token = “Bearer {your_access_token}”;

@Abhijeet_Singh, Generating an auth code and generating access token using the auth code is a three-step process. The first two steps must be completed in a web browser:

  1. Perform Authentication: Access detailed instructions at Perform Authentication .
  2. Receive Auth Code: For this step, visit Receive Auth Code .
  3. Generate Access Token: Finally, to generate the access token, refer to Generate Access Token .

You will receive the auth code on the Redirect URL url in second step which need to be used in process of generating a access token in third step.
The access token is valid for a day an expires at 3:30 AM in the morning.

I recommend reviewing the documentation to better grasp the process here Authentication | Upstox Developer API

I trust this information will be useful.

@Ketan: The first step to Perform Authentication is the blocker here. It asks for a Redirect URI as per the documentation. For a plain console App this step makes no sense. Is there a work around for this? Is the Redirect URI optional?

There is no workaround for this redirect URL. It adheres to the OAuth flow, and a redirect URL is mandatory.

For local testing, you can use http://localhost However, when deploying to your server, you will need a qualified redirect URL to obtain the authentication code. With this code, you can then call the “get token” API, which involves a server-to-server request.

@Pradeep_Jaiswar: I didn’t understand the localhost stuff you are mentioning. How can I test with Localhost?
I will create an App with Redirect URL(localhost). I think the system will let me do it. Now if I invoke the Upstox API with Redirect URL as localhost where will I get the token? In the HTTP response? Worth testing.

You will not directly receive the token; instead, you will obtain an auth token and a redirect url as a query parameter, which you will then use to acquire the access token.

To complete the process from start to finish, follow the step-by-step instructions on this page: Upstox Authentication Documentation.