Question

I'm using the Android AccountManager to authenticate a users google account for access to Google Drive. However, I want to allow the user to access Drive accounts that are not on their phone. For example, I have a work google account that is not on my phone, but I would like to use in my app. Is there a way to allow users to authenticate accounts that are not necessarily stored in the AccountManager?

Thanks

Was it helpful?

Solution

Perhaps you could add another Google account to phone and allow user to select which account to use. If this option doesn't satisfy you and you really want to authenticate to Google Drive accounts not on phone you must then use OAuth.

If you also really, but really, want to use AccountManager facility in your app you have to make an account type that behaves like the following:

  • When you create a new account you open a browser widget and perform an OAuth cycle with Google Drive, then store the token in secure store
  • When you request a token via getAuthToken() it either releases you the stored token or triggers a token refresh cycle using OAuth

This has its security drawbacks: better perform OAuth cycle without AccountManager and store tokens in app memory

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top