At the moment I am trying to find out how to use my Google Drive to store images.
I don't want any user interaction. Users access my web-application then upload files and these files should be stored in my Google drive.
I figured out service account. It works fine, no user interaction. The only problem is storage limit and it is not possible to buy extra to extend it. So we can not use it.
Web application type where I provide redirect URI, sends me code to authenticate to use Drive API. BUT to receive code user should be authenticated and after that I receive code which will allow me to use users Google drive. But here I want to receive code by my account and store images in my Drive.
How can I get rid off user authentication, but use php authentication with my credentials (myaccount#gmail.com) and store files in my drive.
Thanks!
Related
I have a web application which is configured with my mail id. I have functionality of view google drive files in screen. Any user who logged in my site able to view the drive file (located in my mail id).But it is working only if the end user login with Gmail in the same browser. I want my application should work with my mail id that i configured in my system. Every user who logged into my site should able to view the drive file even though they don't have any permission to the drive file. Also I don't want my drive files should be public.so that any one with link cannot view the files. Am using google drive php client v3 for it. I didn't find any code samples regarding this. Any help/clarification is appreciated guys really
I have a web application which is configured with my mail id.
I would be intrested to know how you have achived this, I suspect that you mean you logged in your application using Oauth2 and are running it with the same Oauth2 token.
I have functionality of view google drive files in screen.
I suspect that you mean you can open this file in the Google drive web application. Probably using the weblink from the file.get response.
Any user who logged in my site able to view the drive file (located in my mail id). But it is working only if the end user login with Gmail in the same browser.
Just because your application using the google drive api using your credentials with Oauth2 does not mean that the weblink will open for anyone but you or someone who has been granted access. Anyone who wants to view the file will still have either access to login to your account or have permission on the file from their own google drive account.
I do not recommend you give everyone the login and password to your google account.
I want my application should work with my mail id that i configured in my system.
This is not possible you might be able to get around it using a service account with domain wide delegation to a workspace account but its still only going to give you Google drive api access. It will not give a random person access to a file on your drive account. As the Google drive web application will only show a file that the user has access to.
Every user who logged into my site should able to view the drive file even though they don't have any permission to the drive file.
This may be possible if you set the file to public.
Also I don't want my drive files should be public.
You need to understand the difference between private and public data. Private data is owned by someone, and to get access to that you must have the permission of that person. In order to get permission to access a google drive file if you don't want to set it public you will need to share the file with this person.
so that any one with link cannot view the files.
In that case the file is private and you will need to share it with them.
Am using google drive php client v3 for it. I didn't find any code samples regarding this.
That is because what you want to do is not possible.
comments.
In order to access a file stored on Google drive someone needs to have access to it. Even if you set the file public I suspect the user will still need to be logged into their own google drive account.
Google drive is a file storage system its not meant for file hosting in your application.
Even using a service account will not help you in this case as it sounds like you want to open the file in the google drive web application.
I am trying to upload files into Google Drive using the Google Drive API but the problem is that I have to be logged-in every time. I searched a lot but no luck.
Is there any way I can do authentication process without manual and logged-in intervention?
If you are doing it correctly, you should only have to authenticate once save the refresh token, and use the refresh token in all your other calls.
Second option would be a service account but that is tricky as files are uploaded to the service account, unless you give it permission to upload to your own Google drive account.
How I copy document form one user to another user google drive using google drive api with google service account.
if there is any php code snippet highly appreciate
There is no account to account copy functionality in Google Drive API that I am aware of. You will have to download the file and then upload it to destination account. If both accounts are in your control maybe you can use grive to login the destination account on your machine and download file from source account into desired location via API. Let grive do the upload behind the scenes. This will offload the upload work of the php as well.
Scenario:
Someone comes to my website and they see a file select field. They select the file and upload the file to MY Google Drive account.
Problem:
In looking at the Google Drive SDK docs I see that it uses OAuth for authentication, but I don't need to authenticate the user because they are uploading to MY Google Drive account. I'm aware that I need to register my application with Google, etc. but I'd like to know if I can upload without authorizing the user with OAuth the typical way (sending offsite or modal window to validate w/ redirect URL).
Is this possible to do? I'm using PHP.
You have two options:-
Use a Service Account. The files will be uploaded to the account of the Service Account
Use a regular Google account. For this option, you (as the account owner) will need to do a one-off auth to get a refresh token, which you will store. You can then use this any time to generate the access token needed to invoke the actual Drive API. You can generate the refresh token using the Oauth Playground, so no need to write any code.
See How do I authorise an app (web or installed) without user intervention? (canonical ?)
i wanna make web application use google drive sdk on PHP. when user login to my web using its own credential (ex username : lalala) will automatically login to user google account without user know like background login(silent mode) no redirect to google. username, email and password user save in mysql. user can upload file to google drive with my web application but not redirect to drive.google.com. how to make it? can someone give me an full example, please...
ClientLogin which implements basic authorization is deprecated across the Google products, you need to implement OAuth2 workflow for user accounts.