Exemplo n.º 1
0
        protected void Session_Start(object sender, EventArgs e)
        {
            var request = HttpContext.Current.Request;
            var uriBuilder = new UriBuilder
            {
                Host = request.Url.Host,
                Path = "/Home/Index",
                Port = 80,
                Scheme = "http",
            };
            if (request.IsLocal)
            {
                uriBuilder.Port = request.Url.Port;
            }

            var redirectUri = uriBuilder.Uri.AbsoluteUri;

            // Code that runs when a new session is started
            if (HttpContext.Current.Session["SharpSquare"] != null) return;
            Logger.Error("redirectUri:" + redirectUri);
            var sharpSquare = new SharpSquare(ClientId, ClientSecret);
            var autenticateUrl = sharpSquare.GetAuthenticateUrl(redirectUri);
            Session["AutenticateUrl"] = autenticateUrl;
            Session["RedirectUri"] = redirectUri;
            Session["SharpSquare"] = sharpSquare;
        }
Exemplo n.º 2
0
        protected void Session_Start(object sender, EventArgs e)
        {
            var request = HttpContext.Current.Request;
            var uriBuilder = new UriBuilder
            {
                Host = request.Url.Host,
                Path = "/Home/Index",
                Port = 80,
                Scheme = "http",
            };
            if (request.IsLocal)
            {
                uriBuilder.Port = request.Url.Port;
            }

            var redirectUri = uriBuilder.Uri.AbsoluteUri;

            // Code that runs when a new session is started
            if (HttpContext.Current.Session["SharpSquare"] != null) return;
            Logger.Error("redirectUri:" + redirectUri);
            var sharpSquare = new SharpSquare(ClientId, ClientSecret);
            var autenticateUrl = sharpSquare.GetAuthenticateUrl(redirectUri);
            Session["AutenticateUrl"] = autenticateUrl;
            Session["RedirectUri"] = redirectUri;
            Session["SharpSquare"] = sharpSquare;
        }
Exemplo n.º 3
0
        public ActionResult UserClicksAuthenticate()
        {
            var redirectUri = "http://" + Request.Url.Authority + this.Url.Action("AuthorizeCallback", new { userCode = "userCode" });
            //var redirectUri = "http://www.muhammetkaya.com/redirect_url" + this.Url.Action("AuthorizeCallback", new { userCode = "userCode" });
            var sharpSquare = new SharpSquare(clientID, clientSecret);
            var authUrl     = sharpSquare.GetAuthenticateUrl(redirectUri);

            return(new RedirectResult(authUrl, permanent: false));
        }
Exemplo n.º 4
0
        public void handleCallback()
        {
            try
            {
                string clientId = "CLIENT_ID";
                string clientSecret = "CLIEND_SECRET";
                string redirectUri = "REDIRECT_URI";
                SharpSquare sharpSquare = new SharpSquare(clientId, clientSecret);
                sharpSquare.GetAuthenticateUrl(redirectUri);

            }
            catch (Exception  e)
            {

            }
        }
Exemplo n.º 5
0
 public ActionResult Login()
 {
     return(new RedirectResult(sharpSquare.GetAuthenticateUrl(REDIRECT_URL), false));
 }
Exemplo n.º 6
0
 public virtual ActionResult Authenticate()
 {
     var api = new SharpSquare(ClientId, ClientSecret);
     string authenticateUrl = api.GetAuthenticateUrl(RedirectUrl);
     return Redirect(authenticateUrl);
 }