Android 中多个 Google 数据 API 的单个 Google 帐户身份验证令牌
你好,安卓爱好者,我正在努力寻找解决这个问题的方法。我计划访问用户的 Google 日历和 Google 文档(使用 google-api-java-client-v1.6.0)。我可以通过 AccountManager 访问用户的 Google 帐户,但我没有因为这个原因而在请求 authToken 对用户进行身份验证时搞砸:
当用户确认应用程序访问时,如何在单个 Activity 中处理对 Docs 和 Cal 的多个 authToken 请求他的 Google 帐户?
在我的应用程序中,当用户允许访问用户帐户时,Google Docs 和 Cal 位于在后台运行的不同选项卡上。
任何链接教程将不胜感激。
蒂亚。
Hello android enthusiast, i'm struggling to find solution to this problem. I'm planning to access the user's Google Calendar and Google Documents,(using google-api-java-client-v1.6.0). I can access the user's Google account through AccountManager but I didn't mess up on requesting authToken to authenticate the user for this reason:
How will I handle multiple authToken request for Docs and Cal in a single Activity when the user confirms the application to access his Google Accounts?
In my application, Google Docs and Cal are on different tabs running on background the moment user allows the access of user's account.
any link tutorials would be greatly appreciated.
TYIA.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我的解释正确的话,您想知道如何处理日历需要一个 authToken,文档需要一个 authToken 的事实?
查看一些使用客户端库的示例代码,你能做这样的事情吗:
当你第一次这样做时,用户将看到一个弹出窗口,请求访问他的日历。一旦获得批准,就会出现另一个弹出窗口,询问文档的许可。一旦获得批准,弹出窗口就不会再出现(除非用户重新安装您的应用程序)。所以我认为你不需要担心任何事情。只需确保您第一次尝试在 UI 线程中获取 authToken,而不是在后台进程中获取。在后台进程中,不会出现弹出窗口。
If I interpret you correctly, you are wondering how to handle the fact that you need one authToken for Calendar, and one authToken for Docs?
Looking at some sample code for using the client libraries, could you do something like this:
When you do this the first time, the user will get a popup requesting access to his Calendar. Once approved, another popup should appear asking permission for Docs. Once approval is given, the popups never appear again (unless the user maybe re-installs your app). So I don't think you need to worry about anything. Just make sure that you try to get the authTokens the first time in your UI-thread and not in a background process. In a background process, a popup window will not appear.