Google OAuth2 API的哪些方法接受login_hint作为参数 [英] Which methods of Google OAuth2 API accept login_hint as a parameter

查看:60
本文介绍了Google OAuth2 API的哪些方法接受login_hint作为参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Google登录JavaScript客户端,并引用示例应用

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

The example app (app.js) tells me that login_hint is a valid option for the signIn method:

    // 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()方法有效.在网络上的其他地方,我也看到了与init()方法一起使用的示例.

But the reference manual does not say it does anything there but is only effective with the authorize() method. Elsewhere on the Web I see examples of it being also used with the init() method.

有人可以说明login_hint选项在功能上处于活动状态的任何/所有位置吗?

Can someone please clarify any/all places where the login_hint option is functionally active?

推荐答案

来自 login_hint

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

Optional. If your application knows which user is trying to authenticate, it can use this parameter to provide a hint to the Google Authentication Server. The server uses the hint to simplify the login flow either by prefilling the email field in the sign-in form or by selecting the appropriate multi-login session.

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

Set the parameter value to an email address or sub identifier, which is equivalent to the user's Google ID.

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

To set this value in PHP, call the setLoginHint function:

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

$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);

这篇关于Google OAuth2 API的哪些方法接受login_hint作为参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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