예제 #1
0
        public ActionResult Index(IndexViewModel model)
        {
            if (ModelState.IsValid)
            {
                //  In case of difficulty for the callbac, set up your .hosts (Windows) or etc/hosts file to point a live domain to your localhost IP. such as:
                //  127.0.0.1 xyz.com
                //  where xyz.com is your real domain.

                // following auth process : http://getpocket.com/developer/docs/authentication
                var myPocket = new PocketClient(model.ConsumerKey, Request.Url.AbsoluteUri + Url.Action("Authorized"));

                // Step 2: Obtain a request token
                //To begin the Pocket authorization process,
                //your application must obtain a request token from our servers by making a POST request.
                myPocket.GetAccessToken();
                if (myPocket.AccessToken != null)
                {
                    //Step 3: Redirect user to Pocket to continue authorization
                    //Once you have a request token,
                    //you need to redirect the user to Pocket to authorize your application's request token.
                    var url = myPocket.PocketAuthorizePageUrl();
                    this.Session["GetPocketObject"] = myPocket;

                    return(Redirect(url));
                }
                return(new HttpUnauthorizedResult());
            }
            return(View(model));
        }