gpt4 book ai didi

google-drive-api - 如何通过 API 检查用户是否登录到他的谷歌帐户?

转载 作者:行者123 更新时间:2023-12-02 05:06:48 25 4
gpt4 key购买 nike

我正在开发一个页面来显示用户可访问的文档预览。

为了预览,我使用了 src = https://docs.google.com/viewer?authuser=0&srcid= 的 Iframe {文档编号}

这里的问题是,当用户未登录时,它会显示一个空白的 iframe。

如果当前用户未登录,我想将用户重定向到 google 登录页面,然后显示预览文档的页面。

对于此功能,我必须首先检查用户是否使用 google 登录。

我认为谷歌对 iframe 有一些限制,因此它不会重定向到登录页面。

如何通过 API 实现?

最佳答案

如果您使用 App Engine,请这样做:

要查看显示 google doc 的页面,必须已经检查您是否已登录。

只需配置 Google Users-API。一切都在这里描述:

https://developers.google.com/appengine/docs/java/users/overview

并在web.xml中设置安全约束 https://developers.google.com/appengine/docs/java/config/webxml#Security_and_Authentication

<security-constraint>
<web-resource-collection>
<url-pattern>/page_shows_google_doc</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>*</role-name>
</auth-constraint>
</security-constraint>

关于google-drive-api - 如何通过 API 检查用户是否登录到他的谷歌帐户?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10459720/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com