Need to see if your shared folder is taking up space on your dropbox 👨‍💻? Find out how to check here.

Forum Discussion

Fathzer's avatar
Fathzer
Helpful | Level 6
3 years ago
Solved

Is there a way with java API to get an event when access token is refreshed

Hello,   I'm maintaining a Java Desktop application that can use Dropbox to store user data. I've just discovered that my Dropbox integration doesn't work anymore for new users because of the API ...
  • Fathzer's avatar
    Fathzer
    3 years ago

    After implementation, the solution is not to subclass DbxClientV2. Indeed, the refreshAccessToken method is not called when the client refreshes the token.
    On the other hand, we can pass a subclass of DbxCredential to the constructor of DbxClientV2. DbxCredential's public refresh method is called by the client when the token needs to be refreshed. Then, we can intercept the result of the refresh and do what we want with it.

    Here is an example:

    public class ObservableDbxCredential extends DbxCredential {

    ...

      @Override

      public DbxRefreshResult refresh(DbxRequestConfig requestConfig, DbxHost host, Collection<String> scope) throws DbxException {

        final DbxRefreshResult refresh = super.refresh(requestConfig, host, scope);

        // Insert your code to save the new access token here;

        return refresh;

      }

    }

About Discuss Dropbox Developer & API

Node avatar for Discuss Dropbox Developer & API
Make connections with other developers

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!