Search code examples
c#visual-studioevernote

Authentication on Evernote using C#


I got a problem trying to auth on Evernote using Evernote API key. I am doing

ENSession.SetSharedSessionConsumerKey("my key", "my secret");

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

The ENSession.SetSharedSessionConsumerKey("my key","my secret"); works fine. I mean it doesn't have a return value, so I can't really check. But when I try to Authenticate, using ENSession.SharedSession.AuthenticateToEvernote(); the ENSession.SharedSession.IsAuthenticated is still false. I read here that this method opens a Webbrowser (?) window and asks for auth. Yet nothing happens. So, I am assuming this method calls for a system's preferred web browser, yet again, it seems that it doesn't.

I am using Visual Studio Community 2015, and I've installed Evernote SDK via NuGet.

What's the problem? Is the method broken, or is my VS configured wrong (I haven't yet messed with the VS configuration)


Solution

  • I've found my mistake: searching through the source code of the Evernote API, i've found this:

    ///**
        //*  Set up the session object with an app consumer key and secret. This is the standard setup
        //*  method. App keys are available from dev.evernote.com. You must call this method BEFORE the
        //*  sharedSession is accessed.
        //*
        //*   key    Consumer key for your app
        //*   secret Consumer secret for yor app
        //*   host   (optional) If you're using a non-production host, like the developer sandbox, specify it here.
        //*/
        public static void SetSharedSessionConsumerKey(string sessionConsumerKey, string sessionConsumerSecret, string sessionHost = null)
    

    So i just called SetSharedSessionConsumerKey("key", "secret", "sandbox.evernote.com"); and everything worked.