Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to authenticate multiple accounts in app without checking account‘s password again #160

Closed
yangjieK opened this issue Oct 13, 2017 · 7 comments

Comments

@yangjieK
Copy link

yangjieK commented Oct 13, 2017

I create a app Dropbox API.

I have about@123.com and run@123.com accounts. and authenticate them with one by one.

I log in " about@123.com "
device-2017-10-13-113539_

My question is that When I switch to run@123.com account, how can I authenticate run@123.com without its password ?
The following steps

  1. log out " about@123.com " . I call tokenRevoke()

device-2017-10-13-113934_

  1. switch run@123.com account, and login wtih dropbox, then the website url links to the about@123.com account,so I need logout about@123.com in website to input password and name again.

The question: how to authenticate in run@123.com without input password.

device-2017-10-13-114724_

(Note: Both about@123.com and run@123.com were authenticated a few hours ago)

@yangjieK yangjieK changed the title How to authenticate multiple accounts in app without check account‘s password again How to authenticate multiple accounts in app without checking account‘s password again Oct 13, 2017
@cakoose
Copy link
Contributor

cakoose commented Oct 13, 2017

To keep access to both accounts, do not call tokenRevoke(). Just keep track of the access token and pass that in when you create DbxClientV2.

@yangjieK
Copy link
Author

@cakoose

To keep access to both accounts, do not call tokenRevoke(). Just keep track of the access token and pass that in when you create DbxClientV2.

Will The access token never be changed if I don't tokenRevoke it?

@cakoose
Copy link
Contributor

cakoose commented Oct 13, 2017

By default, the token is valid for years. However, the user can choose to invalidate the token using this page: https://www.dropbox.com/account/connected_apps

If the token expires or the user invalidates the token, when you try to make an API call with that token, you'll get an InvalidAccessTokenException. At that point you can ask the user if they want to re-auth.

@yangjieK
Copy link
Author

@cakoose
thanks,I got this

@yangjieK yangjieK reopened this Oct 13, 2017
@yangjieK
Copy link
Author

yangjieK commented Oct 13, 2017

@cakoose
**Question: Create new Client with different token, why the client doesn't change. **
I try to keep track of the access token between run@123.com and about@123.com. Their token are different. When I switch to about@123.com account and clear old client and recreate a new client with its token, then load mDbxClient.users().getCurrentAccount(),but result info is run@123.com.

So i try to slove it again.but it failed

  1. Auth.startOAuth2Authentication(UserActivity.this, getString(R.string.app_key)) and use about@123.com authenticate

  2. load mDbxClient.users().getCurrentAccount() ,but result info still be run@123.com

@greg-db
Copy link
Contributor

greg-db commented Oct 13, 2017

You'll need a client for the new access token. Are you using DropboxClientFactory though? If so, be careful because that will re-use the old token. You'll need to throw that away and re-initialize it. There's some more information on that here:

#92 (comment)

@yangjieK
Copy link
Author

yangjieK commented Oct 16, 2017

I got it. and it works , the following step

  1. set Client null
  2. clear sharepreference token null
    3.login other account and authenicate
    (Note don't call tokenRevoke)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants