Esempio n. 1
0
        public JObject GetAuthorizationCode()
        {
            JObject response = new JObject();

            var parameters = new Dictionary <string, string>
            {
                { "response_type", "code" },
                { "client_id", _configuration.ClientId },
                { "redirect_uri", _configuration.RedirectURI },
                { "prompt", "login" }
            };

            var requestUrl = string.Format("{0}/authorize?{1}", EndPointUrl, BuildQueryString(parameters));

            var dialog = new WebBrowserDialog();

            dialog.OnNavigated((sender, arg) =>
            {
                if (arg.Url.AbsoluteUri.StartsWith(_configuration.RedirectURI))
                {
                    var collection = HttpUtility.ParseQueryString(arg.Url.Query);

                    foreach (var key in collection.AllKeys)
                    {
                        response.Add(key, collection[key]);
                    }

                    dialog.Close();
                }
            });

            dialog.Open(requestUrl);

            return(response);
        }
Esempio n. 2
0
        public void LogOut()
        {
            var dialog = new WebBrowserDialog();

            dialog.Open(string.Format("{0}/logout", EndPointUrl));
        }