Question

I want to create a little client for Evernote.

I got the consumer key and secret from the site and wrote this code:

struct user_data {
    std::string login;
    std::string pass;
};

struct evernote_data {
    user_data user;
    std::string consumer_key;
    std::string consumer_secret;
};

struct service_data
{
    std::string host;
    std::string path;
    int port;
};

void connect(const evernote_data& account, const service_data&  service)
{
    try
    {
        boost::shared_ptr<TSSLSocketFactory> sslSocketFactory(new TSSLSocketFactory());
        boost::shared_ptr<TSSLSocket> sslSocket=sslSocketFactory->createSocket(service.host, service.port);
        boost::shared_ptr<TBufferedTransport> bufferedTransport(new TBufferedTransport(sslSocket));
        boost::shared_ptr<TTransport> http_client(new THttpClient(bufferedTransport, service.host, service.path));
        http_client->open();
        boost::shared_ptr<TBinaryProtocol> user_store_protocol(new TBinaryProtocol(http_client));
        evernote::edam::UserStoreClient user_store(user_store_protocol, user_store_protocol);

        evernote::edam::AuthenticationResult auth_result;
        user_store.authenticate(auth_result, account.user.login, account.user.pass, account.consumer_key, account.consumer_secret);
        cout << "Some info: " ;
        cout << auth_result.user.username << endl << auth_result.user.name << endl << auth_result.user.email << endl;
    }
    catch(evernote::edam::EDAMUserException& error)
    {
        cout << "catch EDAMUserException" << endl;
        cout << "ErrorCode: " << error.errorCode << endl;
        cout << "What: " << error.what() << endl;
        cout << "Parameter: " << error.parameter << endl;
    }
    catch(::apache::thrift::TException& error)
    {
        cout << "catch thrift::TException " << endl;
        cout << "What: " << error.what() << endl;
    }
    catch(...)
    {
        cout << "boom !!!" << endl;
    }
}

int main()
{
    const user_data user = { "**Login**", "**password**"};
    const evernote_data account = { user, "***Key***", "**Secret**" };
    const service_data service = {"sandbox.evernote.com", "/edam/user", 443 };
    connect(account, service);

    std::cout << "Exit" << std::endl;
    cin.get();
    return 0;
}

Program output:

Catch EDAMUserException 
ErrorCode: 8 
What: Default TException.
Parameter: consumerKey

And always catch error about wrong consumer key. What am I doing wrong?

Was it helpful?

Solution

Third party developers can't use UserStore#authenticate since last November. http://dev.evernote.com/documentation/reference/UserStore.html#Fn_UserStore_authenticate

Please use OAuth instead. http://dev.evernote.com/start/core/authentication.php

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top