Which methods of Google OAuth2 API accept login_hint as a parameter

只谈情不闲聊 提交于 2021-01-27 08:50:14

问题


I am using the Google Sign-In JavaScript client and also referencing the Example App

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 || ''
});

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.

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


回答1:


From the login_hint

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.

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

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

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

Code for you:

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


来源:https://stackoverflow.com/questions/52490476/which-methods-of-google-oauth2-api-accept-login-hint-as-a-parameter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!