Example #1
0
        /// <summary>
        /// This method makes the original call to Evernote to get a token so
        /// that the user can validate that they want to access this site.
        /// </summary>
        /// <param name="reauth"></param>
        /// <returns></returns>
        public ActionResult Authorize(bool reauth = false)
        {
            // Allow for reauth
            if (reauth)
            {
                SessionHelper.Clear();
            }

            // First of all, check to see if the user is already registered, in which case tell them that
            if (SessionHelper.EvernoteCredentials != null)
            {
                return(Redirect(Url.Action("AlreadyAuthorized")));
            }

            // Evernote will redirect the user to this URL once they have authorized your application
            var callBackUrl = Request.Url.GetLeftPart(UriPartial.Authority) + Url.Action("ObtainTokenCredentials");

            // Generate a request token - this needs to be persisted till the callback
            var requestToken = EvernoteAuthorizer.GetRequestToken(callBackUrl);

            // Persist the token
            SessionHelper.RequestToken = requestToken;

            // Redirect the user to Evernote so they can authorize the app
            var callForwardUrl = EvernoteAuthorizer.BuildAuthorizeUrl(requestToken);

            return(Redirect(callForwardUrl));
        }
Example #2
0
        //
        // GET: /Manage/AuthoriseEvernote
        public ActionResult AuthoriseEvernote()
        {
            EvernoteAuthorizer evernoteAuthorizer = new EvernoteAuthorizer(_evernoteOptions.URL, _evernoteOptions.SharedKey, _evernoteOptions.SharedSecret);

            RequestToken requestToken = evernoteAuthorizer.GetRequestToken("http://" + Request.Host.Value + Url.Action("EvernoteCallback", "Manage"));

            HttpContext.Session.SetString("RequestToken", JsonConvert.SerializeObject(requestToken));

            // Generate the Evernote URL that we will redirect the user to in order to authorise
            string callForwardUrl = evernoteAuthorizer.BuildAuthorizeUrl(requestToken);

            return(Redirect(callForwardUrl));
        }