简体   繁体   中英

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. I am using .Net (C#). I just read about accessing the Google Calendar API using the Google APIs Client Library for .NET and tried some basic stuff.

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. 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?

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. 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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM