我正在从事一个Java项目,该项目通过在Evernote上创建的应用程序将Evernote服务集成到其中。目前,除了访问撤销之外,一切都很好。
当一个已经授权应用程序的用户决定不给这个应用程序任何访问权限时,我也想从用户evernote帐户中取消该应用程序的授权。
为此,我正在寻找一些样本,但却空手而归。我找到的一个链接是这,它需要用UserStore调用该方法。我有访问令牌,但不幸的是,我只使用NoteStoreClient,而不是UserStore。
这是我到目前为止拥有的撤销代码。
Person person = this.personService.getCurrentlyAuthenticatedUser();
if (!(person == null)) {
if (person.isEvernoteConsumed()) {
try {
this.evernoteDAO.deleteEvernoteForUser(person.getId());
Evernote evernote = getUsersEvernote(person.getId());
EvernoteAuth evernoteAuth = new EvernoteAuth(EVERNOTE_SERVICE, evernote.getAccessToken());
NoteStoreClient noteStoreClient = new ClientFactory(evernoteAuth).createNoteStoreClient();
}catch (Exception e){
e.printStackTrace();
}
}
}代码里没什么特别的,我知道。如果有人想从Evernote撤销,请告诉我。谢谢。
发布于 2016-02-02 18:53:17
您在正确的轨道上,UserStore方法将允许您撤销您的OAuth会话。正如您所说的,您必须使用userstore客户端,您应该能够像创建notestore客户端那样创建它:
UserStoreClient userStoreClient =
new ClientFactory(evernoteAuth).createUserStoreClient();
userStoreClient.revokeLongSession(evernoteAuth);https://stackoverflow.com/questions/35154802
复制相似问题