1

In sense i want to upload some file to drive.

Now for uploading things to drive through android App I need to authorize Google account with app. Google API Client provide popup for account selection which are store in the phone.

Now i want to authorize app using Constant Email Id and Password where user can be different but the file been uploaded would be uploaded into my account.

Google API client code snippet for popup:

GoogleApiClient mGoogleApiClient = new GoogleApiClient.Builder(this)
        .addApi(Drive.API)
        .addScope(Drive.SCOPE_FILE)
        .addConnectionCallbacks(this)
        .addOnConnectionFailedListener(this)
        .build();   

I want to authorize using Email Id and Password.

Please help me through this as i am new with google drive app.

Ruchit Shah
  • 367
  • 1
  • 2
  • 10
  • similar question to http://stackoverflow.com/questions/27659723/how-to-upload-xlsx-files-to-my-own-google-drive-then-convert-them-to-google-spr/27662555#27662555 and http://stackoverflow.com/questions/27541574/how-to-make-the-google-drive-java-sdk-read-from-write-to-my-drive-and-not-some/27545330#27545330 – pinoyyid Jan 10 '15 at 04:28

1 Answers1

0

Short answer: No, you cannot authenticate using email/password via the API.

the Drive API is largely centered around acting on behalf of the current user, whereas here it should like you want it to act on your behalf, on behest of the current user (who is not you).

A method you could try:

Since you want it to act on your behalf, regardless of the current user, you can set up a server with the appropriate tokens (see: Implementing Server-Side Authorization) which will upload the file for you. Your Android code will then by uploading the file via your server, rather than the Drive API directly.

An alternative method:

If you don't have, or don't want to set up a server of your own, you can always use permissions insert in the API. Basic steps are:

  1. Upload the file to the current user's Drive,
  2. Using the returned file ID, insert a permission for your email address.
Dan McGrath
  • 41,220
  • 11
  • 99
  • 130
  • Hey Dan is their no possibility then server setup because i have a company and all the workers will click some photos that should be stored in company account and i cant share them my company account password. – Ruchit Shah Jan 10 '15 at 06:10