4

我正在使用Google Sign-In JavaScript 客户端并且还引用了示例应用程序

示例应用程序 (app.js) 告诉我 login_hint 是 signIn 方法的有效选项:

    // If the user is not signed in with expected account, let sign in.
return auth2.signIn({
  // Set `login_hint` to specify an intended user account,
  // otherwise user selection dialog will popup.
  login_hint: id || ''
});

但是参考手册并没有说它在那里做任何事情,但只对 authorize() 方法有效。在 Web 的其他地方,我看到它也与 init() 方法一起使用的示例。

有人可以澄清 login_hint 选项在功能上处于活动状态的任何/所有地方吗?

4

1 回答 1

3

login_hint

可选的。如果您的应用程序知道哪个用户正在尝试进行身份验证,它可以使用此参数向 Google 身份验证服务器提供提示。服务器使用提示来简化登录流程,方法是预先填写登录表单中的电子邮件字段或选择适当的多登录会话。

将参数值设置为电子邮件地址或子标识符,相当于用户的 Google ID。

要在 PHP 中设置此值,请调用 setLoginHint 函数:

$client->setLoginHint('user@example.com');

给你的代码:

options = new gapi.auth2.SigninOptionsBuilder();
options.setAppPackageName('com.example.app');
options.setFetchBasicProfile(True);
//options.setPrompt('select_account');
options.setLoginHint('user@example.com');
options.setScope('profile').setScope('email');

auth2.signIn(options);
于 2018-10-04T02:40:11.237 回答