Header is null not able to redirect to get refresh token using backend c#

ashuthinks
ashuthinks edited March 2023 in .Net API client
Hi Team / @sujith
I have written my http trigger function app i'm running it locally for testing.

var client = new RestClient("https://kite.trade");
var request = new RestRequest("/connect/login?v=3&api_key="+MyAPIKey, Method.Post);
request.AddParameter("user_id", "myemail");
request.AddParameter("password", "mypass");
//request.AddParameter("pin", "DO NOT HAVE PIN");
request.AddParameter("redirect_uri", "http://127.0.0.1");
var response = client.Execute(request);

var locationHeader = response.Headers.FirstOrDefault(h => h.Name == "Location")?.Value?.ToString();

var uri = new Uri(locationHeader);
var queryParams = uri.Query.TrimStart('?');
var queryString = HttpUtility.ParseQueryString(queryParams);
var requestToken = queryString["request_token"];

getting locationHeader as null so not redirecting and getting refresh token. is there anay other way like oauth request to get it refresh token directly from backend? I will save my credentials into azure keyvault.
Tagged:
  • sujith
    It is mandatory by the exchange that a user has to manually login at least once a day. We don't recommend automating login.
Sign In or Register to comment.