1

In my app my cloud services are provided by google drive (formely google docs) to interact with google docs I use this library:

http://code.google.com/p/google-api-java-client/

It works great but requires that the device has the Google Apis on it and a google account set up

Is there any other way to authenticate on google docs without using this library? Or do I have to migrate my cloud provider to Dropbox?

Thank you

Claudio Cherubino
  • 14,896
  • 1
  • 35
  • 42
butelo
  • 1,653
  • 1
  • 18
  • 29

1 Answers1

1

Your best bet is to use OAuth 2.0 using the Client-side flow which is designed (partly) for mobile devices.

Basically what you'll have to do is use a Web View and redirect your users to the OAuth 2.0 grant page and then after they have granted you access to their data you simply:

  • Catch the auth code inside the web view
  • Close the web view
  • Exchange the auth code for a refresh and an access token
  • Keep the refresh token in your local database because it gives you unlimited access to the API => no need to trigger Auth flows any more.

That's it! With the newly acquired OAuth 2.0 Access Token and Refresh Token you've got all you need to access the user's Drive data on their behalf and use the API. You've circumvented the Android Account Manager.

There might even be some OAuth 2.0 / Web View client libraries available somewhere for Android, that would help a lot.

PS: this technique is widely used, for instance on iOS if you use the Facebook library, it will first check if there is the Facebook app installed. If the Facebook app is not installed it will use OAuth 2 and the Web View technique automatically. Google's Objective-C client library also uses that technique (as I've heard, never used it).

Nicolas Garnier
  • 12,134
  • 2
  • 42
  • 39