✅ oauth in asp net framework?
hi all, i have created a redirect url for oauth clients
how can i redirect my deployed asp net project in iis to redirect to do the authentication?
this is then authentication controller
public class AuthController : Controller
{
public ActionResult Index()
{
return View();
}
[Route("auth/redirect")]
[HttpGet]
public ActionResult Redirect()
{
string redirectScript = "<html><script>window.location.href=window.location.href.Replace('#', '?').Replace('redirect', 'AuthRedirect')</script></html>";
return Content(redirectScript, "text/html");
}
[HttpGet]
public ActionResult AuthRedirect(string access_token)
{
// Get the full URL from the request
var url = Request.Url.ToString();
// Extract the fragment identifier
var fragment = url.Substring(url.IndexOf('#') + 1);
// Parse the fragment to extract the access_token parameter value
var queryString = HttpUtility.ParseQueryString(fragment);
var accessToken = queryString["access_token"];
var cookie = new HttpCookie("otsession", accessToken)
{
Path = "/",
HttpOnly = true,
};
Response.Cookies.Add(cookie);
return RedirectToAction("Index", "Home");
}
}
this is the oauth link http://localhost:8080/otdsws/login?response_type=token&client_id=<oauth client ID>&redirect_uri=<successful authentication redirect url>&state=none
i have never created an implementation of oauth before.. so any assistance will be appreciated
how can i redirect my deployed asp net project in iis to redirect to do the authentication?
this is then authentication controller
public class AuthController : Controller
{
public ActionResult Index()
{
return View();
}
[Route("auth/redirect")]
[HttpGet]
public ActionResult Redirect()
{
string redirectScript = "<html><script>window.location.href=window.location.href.Replace('#', '?').Replace('redirect', 'AuthRedirect')</script></html>";
return Content(redirectScript, "text/html");
}
[HttpGet]
public ActionResult AuthRedirect(string access_token)
{
// Get the full URL from the request
var url = Request.Url.ToString();
// Extract the fragment identifier
var fragment = url.Substring(url.IndexOf('#') + 1);
// Parse the fragment to extract the access_token parameter value
var queryString = HttpUtility.ParseQueryString(fragment);
var accessToken = queryString["access_token"];
var cookie = new HttpCookie("otsession", accessToken)
{
Path = "/",
HttpOnly = true,
};
Response.Cookies.Add(cookie);
return RedirectToAction("Index", "Home");
}
}
this is the oauth link http://localhost:8080/otdsws/login?response_type=token&client_id=<oauth client ID>&redirect_uri=<successful authentication redirect url>&state=none
i have never created an implementation of oauth before.. so any assistance will be appreciated