예제 #1
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"));
            }
        }