Ejemplo n.º 1
0
        public ActionResult AuthorizationCodeGrant(AuthorizationCodeGrantViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                var client = new WebServerClient(_authServerDescription, viewModel.ClientId, viewModel.ClientSecret);

                var request = client.PrepareRequestUserAuthorization(new[] { viewModel.Scope });

                request.Send();
            }

            return View(viewModel);
        }
Ejemplo n.º 2
0
        public ActionResult AuthorizationCodeGrant(string code, string state)
        {
            ViewBag.Message = "Modify this template to jump-start your ASP.NET MVC application.";

            var model = new AuthorizationCodeGrantViewModel { ClientId = "demo-client-auth-code-identifier", ClientSecret = "demo-client-auth-code-secret-key", Scope = "user" };

            if (!string.IsNullOrWhiteSpace(code) && !string.IsNullOrWhiteSpace(state))
            {
                var client = new WebServerClient(_authServerDescription, model.ClientId, model.ClientSecret);

                this.ViewBag.AccessToken = client.ProcessUserAuthorization(this.Request);
            }

            this.ViewBag.AuthorizationCode = code;
            this.ViewBag.AuthorizationState = state;

            return this.View(model);
        }