0xSingularity
0xSingularity

Reputation: 570

Re-authenticate evernote app C#

The first time I authenticate the app with evernote I was greeted with the evernote sign in page, where I was able to auth my app. After revoking access, I was unable to access functions like uploading notes, or getting the list of notebooks. How can I force the reauth. process to occur again? I.E show the evernote login screen again at app launch. This is currently the code I have in my form.load():

// Be sure to put your own consumer key and consumer secret here.
ENSession.SetSharedSessionConsumerKey("your key", "your secret");

if (ENSession.SharedSession.IsAuthenticated == false)
{
    ENSession.SharedSession.AuthenticateToEvernote();
}

I get no error when I run this, but when I try to upload a note I get this error:

Evernote.EDAM.Error.EDAMNotFoundException

Any help is appreciated, thanks!

Upvotes: 0

Views: 198

Answers (3)

Chris
Chris

Reputation: 1

I know this is an old thread, but I just stumbled across it as I was looking for something related.

It seems the Evernote SDK using ENSession or ENSession advanced does not provide a way to De-Authenticate. However after de-compiling their dll I noticed that there is actually a Unauthenticate method that is private. So in theory you could use reflection so call this method:

  var mi = typeof(ENSession).GetMethod("Unauthenticate", BindingFlags.NonPublic | BindingFlags.Instance);           
  mi.Invoke(ENSession.SharedSession, null);

I am sure that Evernote made this private for a reason so I would be careful calling it, but this should do the trick. I tried this in one of my one Test Applications and after calling Unauthenticate I verified that ENSession.SharedSession.IsAuthenticated is false and calling ENSessionAdvanced.SharedSession.AuthenticateToEvernote() does indeed launch a web browser asking you to log into Evernote.

Upvotes: 0

Max K.
Max K.

Reputation: 1

I haven't tried this, but looks like you can call

ENSession.SharedSession.PerformPostAuthentication();

and then check

ENSession.SharedSession.IsAuthenticated.

If it evaluates to false, then loop back to call

ENSession.SharedSession.AuthenticateToEvernote();

Upvotes: 0

akhaku
akhaku

Reputation: 1157

Looking at the source, it looks like you may be able to set ENSession.SharedSession.IsAuthenticated to false and then call ENSession.SharedSession.AuthenticateToEvernote(). Give that a shot and see if it works?

Upvotes: 0

Related Questions