自动“继续为"文档谷歌弹出 [英] Documentation for the automatic "Continue as" Google popup

查看:124
本文介绍了自动“继续为"文档谷歌弹出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在我的网站上获得自动的使用Google登录"框架之一?如果您登录一个帐户并访问例如Kayak.com,就会发生这种情况.我遇到的任何文档都是针对较旧的使用Google"按钮.

How do I get one of the automatic "Sign in with Google" frames on my site? It happens if you're signed into an account and visit Kayak.com for instance. Any documentation I come across is for the older "Sign in with Google" button.

这就是访问Kayak.com的样子.

Here's what it looks like just by visiting Kayak.com.

推荐答案

编辑(2020年10月29日):

第一个链接现在再次起作用(如 @ManSamVampire 所指出的那样):

The first link is now working again (as pointed out by @ManSamVampire):

https://developers.google.com/identity/one-tap/web

编辑(2019年11月9日):

似乎这些链接现在指向404.我找不到有关One Tap登录消失的任何信息.

It seems the links now lead to 404s. I can't find any information about the disappearance of One Tap sign-in.

原始答案:

我有相同的问题并找到了这个问题(我用Google搜索"google自动登录"):

I had the same question and found this (I Googled "google automatic login"):

https://developers.google.com/identity/one-tap/网络/

它们的屏幕快照是用于移动设备的,但弹出窗口看起来与您在其他Web应用程序上看到的完全相同.

The screenshots they have are for mobile, but the popup looks exactly the same as the one you see on other web apps.

如果您点击指南标签,则应该在其中找到一些文档,其中包括入门部分:

If you click on the Guides tab, you should find some docs there including a Getting Started section:

https://developers.google.com/identity/one -tap/web/入门

这将向您展示如何像设置其他Google API(例如 Maps JavaScript API )一样获得凭据设置.

That will show you how to get the credentials setup just like you would for any other Google API, like the Maps JavaScript API for example.

获得凭据后,就可以从Google的主HTML文件中或任何其他加载脚本的位置加载库,如果有的话:

Once you have your credentials, you load the library from Google in your main HTML file or wherever you load your other scripts, if you have any:

<script src="https://smartlock.google.com/client"></script>

然后,您应该可以通过 googleyolo 对象访问该库:

You should then be able to access the library through the googleyolo Object:

window.onGoogleYoloLoad = (googleyolo) => {
  // The 'googleyolo' object is ready for use.
};

您在该屏幕截图中看到的(以及我也看到的)看起来像是googleyolo.hint()呼叫.

What you are seeing in that screenshot (and what I have seen as well) looks to be a googleyolo.hint() call.

这似乎取决于用户是否已经登录该网站.如果他们已经或在浏览器中保存了该网站的密码,则它应该自动登录或至少提示输入密码.除了使用前面提到的googleyolo.hint()调用的登录之外,该API还可以处理注册.

It seems to be dependent on whether the user has already logged into the site or not. If they have or if they have a password saved for the site in their browser, then it should automatically sign them in or at least prompt for it. This API also handles sign-up's in addition to sign-in's which uses the googleyolo.hint() call mentioned before.

更多详细的代码示例可在指南页面上找到.

More detailed code examples can be found on the Guides page.

您还需要控制此站点的后端,以通过成功的googleyolo.hint()googleyolo.retrieve()调用来验证 ID令牌的完整性.有关内容,请参见 https://developers.google.com/identity/一键式/web/idtoken-auth .

You will also need control over the backend for this site to verify the integrity of the ID tokens from a successful googleyolo.hint() or googleyolo.retrieve() call. That is covered at https://developers.google.com/identity/one-tap/web/idtoken-auth.

这篇关于自动“继续为"文档谷歌弹出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆