[英]Google account access (mail calendar) with Android SDK
I'm completely new to Android development and would like to find out if the following is at all possible, and the best way to approach it: 我是Android开发的新手,我想了解一下以下条件是否可行,以及实现该方法的最佳方法:
That's all for the Google side of things! 这就是Google的一面! I've only ever used Facebook auth - so am unsure as to how Google works.
我只使用过Facebook身份验证-因此不确定Google的工作方式。 I can't seem to find any definitive answers on the web.
我似乎在网上找不到任何明确的答案。
Yes, this is all possible. 是的,这一切皆有可能。
Use Google Play services to get an OAuth 2 access token for the Google APIs. 使用Google Play服务获取Google API的OAuth 2 访问令牌 。 For GMail IMAP and read-only Calendar API access you will need to state these scopes:
对于GMail IMAP和只读Calendar API访问,您需要声明以下范围:
https://mail.google.com/ https://www.googleapis.com/auth/calendar.readonly
Use some IMAP library for Android using your OAuth 2 access token (eg JavaMail , check out this Android JavaMail tutorial and Google's sample for using OAuth2 with JavaMail ). 使用OAuth 2 访问令牌将一些IMAP库用于Android(例如JavaMail ,查看此Android JavaMail教程以及Google的示例,了解如何将OAuth2与JavaMail一起使用 )。
See the Calendar API documentation for how to access the user's calendar. 有关如何访问用户日历的信息 ,请参阅Calendar API文档 。
You can register a web application that uses OAuth to log onto google. 您可以注册使用OAuth登录到Google的网络应用程序。 https://developers.google.com/accounts/docs/OAuth
https://developers.google.com/accounts/docs/OAuth
then you can use GMail API's to use the OAuth token to access user's email https://developers.google.com/google-apps/gmail/oauth_overview 那么您可以使用GMail API使用OAuth令牌访问用户的电子邮件https://developers.google.com/google-apps/gmail/oauth_overview
then for calendar you have the Google Calendar API's also accessed using OAuth. 那么对于日历,您还可以使用OAuth访问Google Calendar API。 https://developers.google.com/google-apps/calendar/
https://developers.google.com/google-apps/calendar/
You can create a web app and use your android app to access your web server database via API's you create. 您可以创建一个Web应用程序,并使用android应用程序通过创建的API访问您的Web服务器数据库。 Using this data you provide a nice GUI for your android users and provide user interactions.
使用这些数据,您可以为Android用户提供一个不错的GUI并提供用户交互。
Another method would be to use only the android client without a web app as mentioned by Jan Gerlinger. 另一种方法是只使用android客户端,而不使用Jan Gerlinger提到的Web应用程序。
You can also check out the source code for k-9 mail app for ideas here: https://github.com/k9mail/k-9 您也可以在此处查看k-9邮件应用程序的源代码以获取建议: https : //github.com/k9mail/k-9
It's a full-featured, open source android email client that supports many protocols including IMAP, SMTP and Microsoft Exchange accounts too. 这是一个功能齐全的开源android电子邮件客户端,也支持许多协议,包括IMAP,SMTP和Microsoft Exchange帐户。 You can dig through the source code to find out how they do it.
您可以深入研究源代码,以了解它们的工作方式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.