You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.

Forum Discussion

Aristide's avatar
Aristide
Helpful | Level 7
8 years ago

How to switch from one account to another java SDK V2 (Android)?

Hello,

Is there a way to switch from one account to another without revoking the accessToken. Since I migrated to V2 I can not manage several accounts with my app.
I always come back to the same account after:

//previously DbxClientV2 created
dropBoxService = null;
//previously String accessToken created
dropboxAccessToken = null;
//start to create a new one
Auth.startOAuth2Authentication(getActivity(), APP_KEY);
//finaly in on resume method:
dropboxAccessToken = Auth.getOAuth2Token();
                
DropboxClientFactory.init(dropboxAccessToken);
dropBoxService = DropboxClientFactory.getClient();
new GetCurrentAccountTask(dropBoxService, new GetCurrentAccountTask.Callback() {
                    @Override
                    public void onComplete(final FullAccount result) {

                        Log.i("DROPBOX",String.valueOf(result.getEmail()));
                        //i obtain the same previously created email and not a new one! Why?
                        
                    }               

SolidExplorer for example switches from one account to another without losing the accessToken. I can not find the trick.

 

Thank you.

  • Ok, Greg K thank you.

    I had this issue because i had used a given class of Android sample.

    DropboxClientFactory.init(dropboxAccessToken);
    dropBoxService = DropboxClientFactory.getClient();


    DropBoxClientFactory.init() method check if the client is null before to initiate a new one.

    Solved for me.

    • Aristide's avatar
      Aristide
      Helpful | Level 7

      Ok, Greg K thank you.

      I had this issue because i had used a given class of Android sample.

      DropboxClientFactory.init(dropboxAccessToken);
      dropBoxService = DropboxClientFactory.getClient();


      DropBoxClientFactory.init() method check if the client is null before to initiate a new one.

      Solved for me.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,910 PostsLatest Activity: 3 days ago
333 Following

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 or Facebook.

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!