I’m trying to upload documents to Google Drive using service account credentials but I’m having trouble seeing the uploaded files in my drive.
I’ve set up the service account properly and downloaded the JSON credentials file from the Google Cloud Console. My authentication seems to work because I don’t get any errors when running the code.
The upload completes successfully and I get a file ID back, but when I check my personal Google Drive, the files are nowhere to be found. What could be causing this issue and how can I make sure the files actually show up in my drive?
Service accounts have their own Google storage - files uploaded through them won’t show up in your personal Drive. Had this exact problem on a project and found two ways around it. First option: create a shared folder between your personal account and the service account. Just grab the folder ID and add it to the metadata when uploading. Second option: switch to OAuth2 so you’re authenticating as yourself and uploading straight to your personal Drive. I went with the shared folder approach since you keep all the benefits of service accounts but still see your files in Drive.
Yeah, this trips up a lot of people. When you upload files with service account credentials, they don’t go to your personal Drive - they go to the service account’s own Drive space. Think of the service account as a completely separate user with its own storage. To see these files in your personal account, you’ve got to share them after uploading. Add this after creating the file: python permission = { 'type': 'user', 'role': 'writer', 'emailAddress': '[email protected]' } drive_api.permissions().create(fileId=result['id'], body=permission).execute() Better option: upload straight to a shared folder that both accounts can access. I’ve done this in my automation projects and it’s way faster - files show up right away without extra permission calls.
omg i had the same issue! just realized that service accounts have their own drive space. you can either share those files with your personal account or switch to oauth for uploads to your main drive. hope this helps!