public ActionResult ClientCredentials() { //Session session = new Session(new Uri("http://localhost:15079/Home/Token")); //IToken token = session.ClientCredentials("refresh") // .ExchangeForToken(); TokenRequest session = new TokenRequest(new Uri("http://localhost:15079/Home/Token")); IToken token = session.ExchangeClientCredentials("12345", "secret"); return View("ClientCredentials", token); }
public ActionResult ResourceOwnerPassword(string username, string password) { //IToken token = session.ResourceOwnerPasswordCredentials(username, password) // .SetClient("12345", "secret") // .ExchangeForToken(); TokenRequest session = new TokenRequest(new Uri("http://localhost:15079/Home/Token")); Session["Token"] = session.ExchangeResourceOwnerCredentials("12345", "secret", username, password); return RedirectToAction("ViewResourceData"); }
public ActionResult RefreshToken() { //Session session = new Session(new Uri("http://localhost:15079/Home/Token")); //IToken token = session.RefreshToken("refresh") // .SetClient("12345", "secret") // .ExchangeForToken(); TokenRequest session = new TokenRequest(new Uri("http://localhost:15079/Home/Token")); Session["Token"] = session.RefreshAccessToken("12345", "secret", "refresh"); return RedirectToAction("ViewResourceData"); }
public ActionResult Callback(string code, string error, string error_description) { if (string.IsNullOrWhiteSpace(error) && !string.IsNullOrEmpty(code)) { TokenRequest session = new TokenRequest(new Uri("http://localhost:15079/Home/Token")); IToken token = session.ExchangeAuthorizationGrant("12345", "secret", code, new Uri("http://localhost:15075/Home/Callback")); //Session session = new Session(new Uri("http://localhost:15079/Home/Token")); //IToken token = session.ExchangeAuthorizationGrant(code) // .SetClient("12345", "secret") // .ExchangeForToken(); Session["Token"] = token; return RedirectToAction("ViewResourceData"); } if (!string.IsNullOrWhiteSpace(error) || string.IsNullOrWhiteSpace(code)) { return View("Callback", new CallbackModel(!string.IsNullOrWhiteSpace(error), error, error_description)); } else { return RedirectToAction("ViewData"); } }