Java – When authenticating with a service account, which account is the Google Drive API used to create files?

When authenticating with a service account, which account is the Google Drive API used to create files?… here is a solution to the problem.

When authenticating with a service account, which account is the Google Drive API used to create files?

I’m trying to use the Google Drive API to send log files created by our app to a company Google Drive account that we share for Android development. Most of the examples show how to use oAuth2 to authenticate an end user’s Google Drive account, but we want to send files only to our Google Drive account.

After some searching, I found that I should create an API project for our application and generate a key using the service account associated with that API project, which we included in our project as a raw resource to authenticate with oAuth2 to get GoogleCredential which is necessary to build the Drive service that we will use to make API calls.

After proper verification, I was able to insert a file using the code sample on the Google Drive API website and the file seems to work fine but I don’t see the file in the Google Drive account where the API project/service account was created. Still, if I call Drive.files().list().execute() and output FileList as a string, I can see the files that our application previously inserted into Google Drive in the service account.

So my question is: is a new Google Drive account created for the service account, which is separate from the Google Drive account that created the service account? If so, is there a way to log in to that account and view the files using the normal Google Drive web UI so that we can access the log files without having to write some other application to authenticate the service account and then get the files?

Solution

It seems that my question ended up being a duplicate, and another issue was a bit hard for me to find. The question isI can’t see the files and folders created via code in my Google Drive A Google employee answered the question: https://stackoverflow.com/a/12218662/994519

Related Problems and Solutions