Nikolay Ignatyev
Nikolay Ignatyev

Reputation: 123

How to authenticate with Evernote developer account with OAuth.io

I have a task to create SPA that will be using Evernote account data. For authetication I want to use Oauth.io service. "Try auth" button from Oauth.io site works fine. I see popup with prompt to sign in.

In my app html I have a simple button:

<button id="login-evernote-btn" type="button" class="bx-button bx-button-accept" onclick="app.loginWithEvernote();"><i class="fa fa-sign-in"></i> Evernote Login</button>

and my JS application:

//Constructor
function Application() {
    OAuth.initialize('HERE_PASTE_MY_PUBLIC_KEY');
};

/*----------------------------*/
/*    Application methods     */
/*----------------------------*/

Application.prototype.loginWithEvernote = function() {

    OAuth.popup('evernote', function(error, success){

    });
};

// Create application Object
app = new Application();

But after clicking on my button I see splash window that closing in second. I can't enter my credentials.

What step I am doing wrong?

After successful authetication I want to use Evernote API to list all notes.

Upvotes: 2

Views: 97

Answers (1)

bumpmann
bumpmann

Reputation: 685

You need to log the error to see what is the problem with the popup. That maybe the domain whitelist or using 'evernote' provider instead of 'evernote_sandbox'

According evernote-sdk-js on github, you can use your token this way

Application.prototype.loginWithEvernote = function() {
    OAuth.popup('evernote').done(function(evernote) {

        var client = new Evernote.Client({token: evernote.oauth_token});
        var noteStore = client.getNoteStore();
        notebooks = noteStore.listNotebooks(function(err, notebooks) {
           // run this code
        });

    }).fail(function(e) {
        console.error(e)
    });
};

Upvotes: 2

Related Questions