简体   繁体   English

使用用户名/密码访问Google Calendar API

[英]Access Google Calendar API with username/password

I am writing a small client to sync the outlook calendar on a machine with a user's google calendar. 我正在写一个小客户端来同步一台机器上的Outlook日历与用户的谷歌日历。 I am using .Net (C#). 我正在使用.Net(C#)。 I just read about accessing the Google Calendar API using the Google APIs Client Library for .NET and tried some basic stuff. 我刚刚阅读了有关使用适用于.NET的Google API客户端库访问Google Calendar API的信息,并尝试了一些基本内容。

Now regarding the Authorization, as far as I understood, the new "OAuth 2.0" Authorization requires a "user consent", which means the user is directed to a google page where they must explicitly allow my application access to their calendar. 现在关于授权,据我所知,新的“OAuth 2.0”授权需要“用户同意”,这意味着用户被定向到谷歌页面,他们必须明确允许我的应用程序访问他们的日历。 As if this user interaction is not enough, I as a programmer have to handle "access tokens" or "refresh tokens" and all that stuff. 好像这个用户交互还不够,我作为程序员必须处理“访问令牌”或“刷新令牌”以及所有这些东西。

Now my question is: Is there really no easier way to have an installed application communicate with the google API to access a user's calendar? 现在我的问题是:是否真的没有更简单的方法让安装的应用程序与谷歌API通信以访问用户的日历?

I would like my user to enter his username/password in a "Settings" dialog. 我希望我的用户在“设置”对话框中输入他的用户名/密码。 His credentials would be stored locally (encrypted of course) and then be used later on every access via google API. 他的凭据将存储在本地(当然是加密的),然后通过google API在以后的每次访问中使用。 I know this can be dangerous and all that however I would like that decision to lie with me. 我知道这可能是危险的,但是我希望这个决定能够和我说谎。

So, is that possible? 那么,这可能吗?

No that is not possible. 不,这是不可能的。 The entire point of OAuth is the user never gives a 3rd party (you) their username and password. OAuth的全部意义在于用户永远不会向第三方(您)提供其用户名和密码。 The only thing you get is a token that allows you to connect that the user can revoke at any time. 您唯一获得的是一个令牌,允许您连接用户可以随时撤消的令牌。 (Also if the user changes his password, you can still use the same saved token and do not need to make the user update their settings). (此外,如果用户更改了密码,您仍然可以使用相同的已保存令牌,而无需让用户更新其设置)。

If you decide to "work around" this by saving the username and pasword and performing the "authorization" yourself you will be in violation with the TOS of the API and will have your application banned by Google (or any OAuth provider if you try it with someone else) for not following the rules. 如果您决定通过保存用户名和密码以及自行执行“授权”来解决此问题,那么您将违反API的服务条款,并且您的应用程序将被Google(或任何OAuth提供商禁止,如果您尝试使用与其他人一起)不遵守规则。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在没有用户名/密码的情况下访问Google Analytics(分析)数据 - How to access google analytics data without username/password 如何在没有用户名和密码的情况下访问 REST API 方法 - 但只能使用令牌? - Howto access REST API methods without username and Password - but only with a token? 使用服务帐户身份验证访问 Google Calendar API - Access Google Calendar API using Service Account Authentication Google Calendar API ServiceAccountCredential - Google Calendar API ServiceAccountCredential 无法使用正确的用户名和密码访问API(c#-HttpClient)-未经授权的请求 - Cannot access API with correct username and password(c#-HttpClient)-Unauthorized Request 从ms Access数据库检查用户名和密码 - checking username and password from a ms access database 使用路径中的用户名和密码访问远程Windows PC - Access to remote Windows PC with username and password in path 如何在MS Access中设置用户名和密码 - how to set username and password in ms access 使用用户名和密码通过 Cognito 获取访问令牌 - Getting Access Tokens with Cognito using Username and Password 如何检查访问数据库中的用户名和密码 - How to check username and password in access database
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM