I'm trying to make a service that runs on a webserver and can upload files to Google Drive,
so that people can sync the files to local-drive using the Google desktop application.
So I tried the Drive API but it requires a webbrowser to authenticate.
This would be a possibility, but I don't know to get the access token programmically.
Even if I had the access token, I wouldn't know if it just works forever.. It seems to have an expire date?
I wouldn't want the service to suddenly not working, because the token has expired.
Than I learned about Service Account, and finally got it working, but it seems to have its own space that i can only access with the service account.
I don't know how to share the files from the service account to a regular account, as people need to sync it locally.
So a found a video about user impersonation, in which he showed a page about given access to a service account to impersonate another user.
But i don't know where to find this page.
Looking at: http://support.google.com/a/bin/answer.py?hl=en&answer=162106&topic=2759255&ctx=topic
It says it's in Advanced Tools > Manage third party OAuth client access (under the Authentication section).
But where is the Authentication section? Do I need to create a Google App to do this?
The question is: How upload files programmically to Google Drive without any user intervention, so that they can be synced locally with the drive desktop-application.
Related
What will extra setting to get files / folder from google drive API with service account? Currently getting empty results.
Same code working with credential web scope with client id and secrets key but not with service account.
When you use a web client. It pops up and requests authorizaiton. In this way a user is granting your application access to their data. So a file.list will return the files on the users google drive account.
The same thing is happening with your service account. Only service accounts are pre authorized. Your file.list is returning no files becouse the service account doesnt have acess to any files yet. You see it has its own drive account.
Options.
Upload files to the service accounts drive account.
open your credetials.json file. Look for the service account email address. Take that address and share a directory or file on your personal drive account with the service account.
Now do a file.list. It should have files.
Hi i'm trying to make my own cloud web service that uses python google drive API.
what i'm trying to make is basically cloud service but can also interact with Google Drive.
To do that, my web service users have to have their own 'storage.json' file in their server's virtual directory (which really stores in server).
when I somehow get my own 'storage.json' file, (I followd: https://developers.google.com/drive/api/v3/manage-uploads)
and upload 'storage.json' file to my directory like User1, upload and download with Google drive works just fine.
but my final goal is when my user doesn't have 'storage.json' file in their directory like User2, I want browser to pops up in User2's computer and User2 can follow the google's authentication flow and finally download 'storage.json' file into server's ~/User2/ directory.
Do you think this is possible? or if there are better ways, can you notice me? thank you
I'm trying to get the Cyberduck CLI (duck.sh) to work interfacing with a google drive (not "Google Cloud Storage") and I'm having problems getting the oAuth authorization to work. I found this thread but it's out of date - as the newer versions of Cyberduck do absolutely work with Google Drive. Using the regular cyberduck GUI I can browse and operate on my G-drive instance, but I can't quite quack the code (sorry!) for how to make this work using the CLI.
[lwobker:~]$ duck -l googledrive://<user>#gmail.com/
Authenticating as <user>…
OAuth2 Authentication. Paste the authentication code from your web browser.
Authentication Code: <pasted pass here>
Save password (y/n): n
Disconnecting www.googleapis.com…
Login failed. Malformed auth code. Please contact your web hosting service provider for assistance.
I've tried a number of different URLs, including:
#gmail.com
me#gmail.com#www.googleapis.com
and a couple of others.
I also can't seem to figure out where the GUI version of cyberduck stores it's authorized credentials... if I could re-use those that would be fine, doing a one-time setup at the beginning doesn't break my use case.
I'm somewhat familiar with the Google Developers API, and I've created one for use with this project, but I can't seem to figure out how the Google "Client ID" and other credentials map to the Cyberduck tool.
Make sure you paste the auth code obtained from the Google login page opened exactly as is without any line breaks. More information is available in the wiki.
I have had a look at some of the oAuth2 documentation and a few of the Developer videos. Tried to follow some examples but failed - never tried anything but VBA before.
My question is will this be possible?
What I would like to do is log out a user after they accept my app and log back in as a specific user in our domain for them to download a Chrome extension.
User accepts setup for uploading to database
App logs out user and logs in DB-Account
Relevant URL is opened in Chrome
Save to Google Drive extension is downloaded by user
Setup complete - yes, will sign out the DB-Account from Chrome
Can I authenticate with just Google account username and password instead of using OAuth? If not, is it planned to support this kind of authentication in the future versions of Google Drive API?
I am currently using Google Documents List API which allows to authenticate with just username and password. So I am wondering if I can I do the same thing with Google Drive API.
Are there any reasons you cannot use OAuth 2.0 as your authorization mechanism?
Client Login is currently being deprecated and it would be better for you and your users to use OAuth 2.0.
There are multiple code samples available in the Drive SDK documentation as well as in the various client libraries project page to help you get started.
If you are running a server application, consider using a service account with OAuth2 and the Drive API. This will allow you to run the app on a server without a user having to provide OAuth2 credentials on the console or through a UI. You can also do impersonation if you want your app to act on documents with a specific account.
GoogleCredentials credentials = new GoogleCredential.Builder()
.setTransport(HTTP_TRANSPORT)
.setJsonFactory(JSON_FACTORY)
.setServiceAccountId("[[SERVICE_ACCOUNT_EMAIL]]")
.setServiceAccountScopes(DriveScopes.DRIVE, DriveScopes.DRIVE_FILE,
"https://www.googleapis.com/auth/userinfo.email",
"https://www.googleapis.com/auth/userinfo.profile")
.setServiceAccountPrivateKeyFromP12File(Auth.keyFile)
.setServiceAccountUser("[[impersonateduser#domain]]")
.build();
credentials.refreshToken();
I've found this blog post somewhere (possibly here): http://blog.databigbang.com/automated-browserless-oauth-authentication-for-twitter/.
I know it is regarding Twitter, but it uses the same method, so I reckon it just needs a little tweak in the names. In short: if the script is run only by server, install Jython + HTMLUnit, simulate user going to the generated authorization link and clicking 'allow access' button and get token.