Java, Evernote : Revoke access for app on Evernote

蓝咒 提交于 2019-12-13 19:04:05

问题


I am working on a Java project which has Evernote services integrated into it through an app created on Evernote. Currently, everything is working fine except for access-revocation.

When an user who has already authorized the app, at some point decides not to give this app any access, I would like to also de-authorize the app from the users evernote account.

For this, I am searching for some sample, but came empty handed. One link I found was this, where it was required to call that method with UserStore. I have the access-token, but unfortunately I am only working with NoteStoreClient, rather than UserStore.

Here is the revocation code I have so far.

 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();
                }
            }
        }

Nothing fancy in that code, I know. If anyone has any idea of revocation from Evernote, kindly let me know. Thank you.


回答1:


You're on the right track, that UserStore method will let you revoke your OAuth session. Like you said, you have to use the userstore client instead, you should be able to create it the same way as you did the notestore client:

UserStoreClient userStoreClient =
  new ClientFactory(evernoteAuth).createUserStoreClient();
userStoreClient.revokeLongSession(evernoteAuth);


来源:https://stackoverflow.com/questions/35154802/java-evernote-revoke-access-for-app-on-evernote

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!