Example #1
0
        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);
        }
Example #2
0
        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");
        }
Example #3
0
        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");
        }
Example #4
0
        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");
            }
        }