Fully working example of uploading a file to Google Drive using a service account.
Sharing a folder
This sample can upload to the root directory of the service account or you can specify a directory to upload the file to.
To upload it to a directory on your personal drive account you must share a folder with the service account. Go to the google drive web app and share the folder with the service account as you would share it with a user.
The service account email address can be found in your json key file.