使用电子邮件地址上传到云端的文件云端、电子邮件地址、文件

2023-09-03 06:59:31 作者:爱的鼾欢

所以,我不知道这是否是可能的,如果它是决策意识都没有。我想学习和使用云空间在我的应用程序。因此,作为一个示例中,我试图创建上传文件在谷歌驱动器的应用程序。我注册了我的申请和使用的谷歌给出了一些参考。而我现在能够上传文件。

我用 myname@gmail.com 和注册使用我的应用程序 CLIENT_ID Client_Secret 给我的帐户创建应用程序。当我上传的文件,文件被上传到我的 myname@gmail.com 帐户。但我要的是,我的应用程序应该给一个选项,用户登录到有的Gmail 帐户。谁登录(说与电子邮件 your@gmail.com ),我的应用程序应该能够将文件上传到那里的帐户。我相信谷歌离线硬盘应用桌面的工作方式相同。输入您的用户名和密码,将文件同步到该帐户。任何人都可以点我一个样品code吗?

我要上传的文件,阅读它们,删除它们,通过我的应用程序共享。我不会给任何code样品,但如果需要让我知道。谢谢你。

解决方案

您可以做到这一点。您将需要导航的用户到特定的URL,在那里他将投入他的电子邮件和密码。之后,谷歌会给你授权code和刷新令牌。刷新令牌可用于检索授权code每当它已过期。 此授权code用于与用户开车去上班。

如果您的应用程序是一个Web应用程序,您可以导航用户使用Google,并设置回调到您的自定义URL。 如果它是一个Windows窗体应用程序,那么你有2个选项

创建自定义浏览器窗口,并解析DocumentTitle财产 在浏览用户的浏览器,并要求他复制粘贴code,从标题(或自动执行) 发送邮件方便快捷

您可以下载从这里

只需填写 CLIENT_ID CLIENT_SECRET 常量。

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.