Upload to Google Drive use C# - c#

I have a problem. I use C# .Net 2013 Windows Form Application. I want to upload to Google Drive the file of the user selected.(The user cannot have a gmail account.) The project can work in any copmuter as .exe. However, the project wants to login in each case when I try. When I logged in, the project wants to allow from me. I don't want to this. Users will select the files they want to send and after that they will click on the send button. Users should not see any question. The selected file should be sent automatically. How can I do this?
Thanks for your help. Emrah.

It sounds like you want end users to upload files to a single Google Drive account. In that case you should probably look into using a Service Account, which allows the application to have it's own account without prompting the user for authorization.

Related

Downloading files into specified location on client's machine without user interaction asp .Net

I have a webpage where user's can select the files from a list view and click on a download button to download the files. This is not a public site. I want the selected files to download into a specified location and if the location does not exist then I want to create the location. I don't any save dialog or user interaction.
I understand that this is a security problem as any site could download files into a location on the client's pc without them knowing.
Can someone give me a solution or provide some knowledge on how to do this? Or can you confirm that this is not possible please. Thanks
User's access the site on locked down kiosks, tablets and laptops. All which need to be used offline.
If I understand correctly, this is your setup
You have a web sever
You have a kiosk which shows web pages reading from that web server
User uses the kiosk, while on the web page, selects some files in the list and hits some button
Your requirement
You want those selected files to be saved on kiosk or some other PC available on the same network, without having save file dialog?
For above requirement you can do this,
Create a folder on kiosk/network computer and share it
Make sure web server can access the shared location
When user clicks on the button on web page
Do a post back on server (using AJAX or regular post-back), then on the web server, save the files in the shared folder and provide a success response to the end user
BTW I am NOT sure how you will be able to access those files (saved in kiosk) using the browser, if that is also required.

Drive.API.v3 Different Accounts username / password authentication

So I have a few accounts that have documents on them, and having to switch between them all the time is quite frustrating, so I wanted to have them shared so that I can just have a link to view the file (no editing or anything).
Problem is, now with v3, I seemingly have to add the Drive API to every account that I want to view, which doesn't work for me. It's too much of a hassle to go through ALL of the accounts, when I have the username/password for them all already.
Is there a way to have a list of all my accounts username/passwords and somehow query to get a token to view only of the files? Or is this completely not possible anymore with v3.
I can get it working fine but instead of username/password, I have to enable drive API on the account, copy/paste the credential/secret instead of the username/password, and it works perfectly. I can search through all the files I have 'found' by accessing and reading the files and AlternateLink's accordingly... I just would like a non-intrusive way for my application to do this.
This is written in C#.
Unfortunately you can no longer use username/password via an API since the ClientLogin API was shutdown in 2015.
Using OAuth, each user can be prompted to grant permission to your application. They need do this only once.
Alternatively and if the user accounts are GSuite based Google accounts, then your C# program could use a single service account and impersonate any or all accounts on your domain (once given permission to do that by your domain administrator). This obviates the need for each user to grant permission to your application. You can read about how to do this in the Delegating domain-wide authority to the service account doco.
Another alternative may be to create a google group and make all 3 accounts members of that group. Then share a folder (view, comment or edit access) with that group and put all files and sub folders there into that folder.

upload file to google drive windows forms c#

Basically the idea of ​​the program is as follows: The user enters their email account and password google drive, then select the file and click upload button.
Can this be done?
Yes, but you have to have an embedded browser to handle the authentication using OAuth, as the client will need to enter their credentials into the Google login page. A previous answer here How to publish Google Docs in .NET? also indicates there is a .net library (which I havent tried) that might help.

Upload files on cloud using email address

So I am not sure if it is possible and if it is making sense at all. I am trying to learn and use cloud space in my application. So as a sample I was trying to create an application to upload files in Google Drive. I registered my application and used some references given by Google. And I am able to upload files now.
I registered my app using myname#gmail.com and used Client_Id and Client_Secret given in my account to create the app. When I upload the files, files get uploaded to my myname#gmail.com account. But what I want is, my app should give an option to user to login into there gmail accounts. Whoever logs in (say with email your#gmail.com), my app should be able to upload files to there account. I believe offline Google Drive app for desktop works the same way. Enter your username and password and files will sync to that account. Can anyone point me to a sample code please?
I want to upload files, read them, delete them, share them through my app. I am not giving any code sample, but if its needed let me know. Thanks.
You can do it. You will need to navigate user to a specific URL, where he will input his email and password. After that Google will give you authorization code and refresh token. Refresh token can be used to retrieve authorization code whenever it is expired.
This authorization code is used to work with user drive.
If your application is a web application you may navigate user to google and set callback to your custom URL.
If it is a windows forms application, then you have 2 options
Create custom browser window and parse DocumentTitle property
Navigate user's browser and ask him to copy-paste code from title (or do it automatically)
You may download an example from here
Just fill CLIENT_ID and CLIENT_SECRET constants.

Adding Windows Live ID to the credential store

I have written an application that maps a user's SkyDrive to a network drive.
However when opening word documents directly from the network drive, Microsoft Office 2010 tries to load the document using WebDav and prompts for the user to login in again.
When you login it works fine, and if you click "Remember Me" it stores the credentials in the credential store, accessible via rundll32.exe keymgr.dll, KRShowKeyMgr
This only lasts until the session is closed.
I want to incorporate the automatic storing of the user's credentials into my program so that the user doesn't get prompted at all.
I have tried using the CredWrite API however that only allows me to store generic credentials. I need to store a (.Net Passport) credential.
http://msdn.microsoft.com/en-us/library/windows/desktop/aa375187(v=vs.85).aspx
I have only been able to achieve this using the CredUIPromptForCredentials API with the flags set to CREDUI_FLAGS_SERVER_CREDENTIAL
http://msdn.microsoft.com/en-us/library/windows/desktop/aa375177(v=vs.85).aspx
I have inspected the API call that word makes to credui.dll and it is identical to the one I am calling (aside from some captions).
But it produces different results.
My code produces this credential to be saved
The word api call/subsequent code produces this credential
However I cannot figure out how to get the credential target to save correctly so that office will load it without prompting. I'd prefer to even have the prompt load if there is no option as I can pre fill the username and password so that the user just has to click OK but I'd like to do it silently.
Additionally if there is anyway to disable word's WebDav support/force it to use the network drive as an actual network drive that would also work. I have been unable to find any answer. If anyone has any idea I would greatly appreciate it.

Categories

Resources