4

下面的代码工作正常,但从隐身 Windows 控制台打开时只显示

GoogleYolo loaded.
No credentials

<html>
<head><title>My Yolo Login example</title>
<script src="/common.js"></script>
<script defer src="https://smartlock.google.com/client"></script>
 <script>
      

      const PUBLIC_CLIENT_ID =
          '*******-**********.apps.googleusercontent.com';
      const CONFIG = {
        supportedAuthMethods: [
          'googleyolo://id-and-password',
          'https://accounts.google.com'
        ],
        supportedIdTokenProviders: [{
          uri: 'https://accounts.google.com',
          clientId: PUBLIC_CLIENT_ID
        }],
	context:"signUp"
      };
      window.onGoogleYoloLoad = (googleyolo) => {
        console.log("GoogleYolo loaded.");
	var retrievePromise = googleyolo.retrieve(CONFIG);
        retrievePromise.then((credential) => {
        	console.log(credential);          

        },
	(error)=>{
	if(error.type == "noCredentialsAvailable"){
		console.log("No credential");
		googleyolo.hint(CONFIG).then((credentials)=>{console.log(credentials);});}	
	});
      };
    </script>   

</head>


</html>

我怎么知道用户没有谷歌账户并重定向/采取其他行动让他登录到他的谷歌账户。

4

1 回答 1

3

我是这个库的谷歌产品经理。我们正在为未登录的用户提供更好的支持,但在此期间,当没有 Google 帐户处于活动状态且没有可用的凭据时,您可以简单地显示传统的 Google 登录按钮并让用户单击以继续通过流程在浏览器中激活他们的 Google 帐户。

https://developers.google.com/identity/sign-in/web/

于 2017-12-04T06:17:41.177 回答