Exemple #1
0
        public ActionResult AuthorizeCallback(string code, string userCode)
        {
            var redirectUri = "http://" + Request.Url.Authority + this.Url.Action("AuthorizeCallback", new { userCode = userCode });

            var sharpSquare = new SharpSquare(clientID, clientSecret);

            var accessToken = sharpSquare.GetAccessToken(redirectUri, code);

            // need this in order to make calls to API
            // it's redundant because token is already set in GetAccessToken() call but it helps to understand the workflow better.
            UserLoginInfo u1 = new UserLoginInfo();

            using (CheckinDatasetEntities4 db = new CheckinDatasetEntities4())
            {
                var UserLogID = (from p in db.UserLoginInfo
                                 where p.USERNAME == User.Identity.Name
                                 select p.USERLOGINID).FirstOrDefault();
                string token = accessToken;
                db.Token.Add(new Token()
                {
                    TOKENACID   = token,
                    USERLOGINID = UserLogID
                });
                db.SaveChanges();
            }
            //CheckinOperations.insertUSerLoginInfo(u1);

            return(RedirectToAction("Index", "Home"));
        }
 public virtual ActionResult Authorize(string code)
 {
     if (string.IsNullOrWhiteSpace(code))
     {
         return Json("Failed to authenticate");
     }
     var api = new SharpSquare(ClientId, ClientSecret);
     string token = api.GetAccessToken(RedirectUrl, code);
     api.SetAccessToken(token);
     var user = api.GetUser();
     // todo store token to user
     using(var context = new FourWarContext())
     {
         /*
         var user = context.Users.Create();
         user.OAuthToken = token;
         user
          * */
     }
     return RedirectToAction(MVC.Home.Index());
 }
Exemple #3
0
        public ActionResult AuthorizeCallback(string temp, string code)
        {
            HttpContext.Session["AccessToken"] = sharpSquare.GetAccessToken(REDIRECT_URL, code);

            return(new RedirectResult(BASE_URL, false));
        }