cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements
Update: Find information on Dropbox support during COVID-19 here
Close
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted

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

Helpful | Level 6

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.

1 Accepted Solution

Accepted Solutions
Highlighted

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

Helpful | Level 6

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.

View solution in original post

2 Replies 2
Highlighted

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

Dropboxer
Dropboxer

The access token you use identifies which account you connect to. You can store and re-use multiple different access tokens to support using multiple different accounts.

 

There's some more information here:

 

https://github.com/dropbox/dropbox-sdk-java/issues/92

Highlighted

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

Helpful | Level 6

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.

View solution in original post

Work Smarter with Dropbox

The way we work is changing. Share and discover new ways to work smarter with Dropbox in our community.

Sound good? Let's get started.
Who's talking

Top contributors to this post

What do Dropbox user levels mean?
Need more support?