我的任务是创建将使用 Evernote 帐户数据的 SPA。对于身份验证,我想使用 Oauth.io 服务。 Oauth.io 网站上的“尝试身份验证”按钮工作正常。我看到弹出窗口,提示登录。
在我的应用程序 html 中,我有一个简单的按钮:
<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>
和我的 JS 应用程序:
//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();
但是单击我的按钮后,我看到启动窗口随即关闭。我无法输入我的凭据。
我哪一步做错了?
成功验证后,我想使用 Evernote API 列出所有笔记。
最佳答案
您需要记录错误以查看弹出窗口的问题所在。这可能是域白名单或使用“evernote”提供商而不是“evernote_sandbox”
根据evernote-sdk-js在 github 上,您可以通过这种方式使用您的 token
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)
});
};
关于javascript - 如何使用 OAuth.io 对 Evernote 开发者帐户进行身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35988291/