示例#1
0
        public EvernoteServiceSDK1(EFDbEvernoteCredentials credentials)
        {
            this.credentials = credentials;

            THttpClient noteStoreTransport = new THttpClient(new Uri(credentials.NotebookUrl));
            TBinaryProtocol noteStoreProtocol = new TBinaryProtocol(noteStoreTransport);
            noteStore = new NoteStore.Client(noteStoreProtocol);
        }
示例#2
0
        // 
        // GET: /Manage/EvernoteCallback
        public async Task<ActionResult> EvernoteCallback([FromQuery] string oauth_verifier)
        {
            EvernoteCallbackViewModel evernoteCallbackViewModel = new EvernoteCallbackViewModel();

            if (String.IsNullOrEmpty(oauth_verifier))
            {
                throw new ArgumentNullException(nameof(oauth_verifier), "Problem authenticating Evernote: did not receive OAuth verifier");
            }

            EvernoteAuthorizer evernoteAuthorizer = new EvernoteAuthorizer(_evernoteOptions.URL, _evernoteOptions.SharedKey, _evernoteOptions.SharedSecret);

            RequestToken requestToken = (RequestToken)JsonConvert.DeserializeObject(HttpContext.Session.GetString("RequestToken"), typeof(RequestToken));

            EvernoteCredentials evernoteCredentials = evernoteAuthorizer.ParseAccessToken(oauth_verifier, requestToken);

            EFDbEvernoteCredentials efdbEvernoteCredentials = new EFDbEvernoteCredentials(evernoteCredentials);

            var user = await GetCurrentUserAsync();

            if (evernoteCredentials == null)
            {
                evernoteCallbackViewModel.ErrorMessage = "You did not authorise application";
                user.HasAuthorisedEvernote = false;
            }
            else
            {
                evernoteCallbackViewModel.SuccessMessage = "Evernote successfully authorised, you can now search for notes and start reading";

                _dataAccess.UpdateEvernoteCredentials(efdbEvernoteCredentials);

                user.HasAuthorisedEvernote = true;
                user.EvernoteCredentials = efdbEvernoteCredentials;
                user.EvernoteCredentialsId = efdbEvernoteCredentials.Id;
            }

            await _userManager.UpdateAsync(user);

            return View(evernoteCallbackViewModel);
        }
 public void UpdateEvernoteCredentials(EFDbEvernoteCredentials evernoteCredentials)
 {
     _dbContext.EvernoteCredentials.Add(evernoteCredentials);
     _dbContext.SaveChanges();
 }