javascript - 如何将 login_hint 传递给 gapi.auth.authorize?

标签 javascript google-api google-oauth

我似乎记得 gapi.auth.authorize 有一个参数来指定一个 login_hint 来绕过帐户选择器。但我可能会谷歌,我找不到它。这只是一个梦吗?

我的问题是我遇到了帐户选择器在当前窗口下弹出的问题,因此用户错过了。

或者另一种提问方式可能是,像 login_hint 和 incremental auth 这样的参数如何 https://developers.google.com/accounts/docs/OAuth2UserAgent#incrementalAuth由 Javascript 库公开?

最佳答案

谷歌的 OAuth 2.0 documentation, under the heading Forming the URL , 表明接受了 login_hint 参数(例如,login_hint=email@fake.com)。

JavaScript Client Library documentation, under gapi.auth.authorize , 状态:

If the key is not one of the expected OAuth 2.0 parameters (see below), it is added to the URI as a query parameter.

所以你应该能够做到这一点:

gapi.auth.authorize({
    // Parameters here...
    'login_hint': 'email@fake.com',
    // ...Parameters here
}, callbackFunc);

库将在请求 URL 中包含 login_hint 参数。

关于javascript - 如何将 login_hint 传递给 gapi.auth.authorize?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21942977/

相关文章:

javascript - 纯 css 单击下拉菜单在 IE10 和 IE11 中不起作用

javascript - jQuery:从 HTML 页面获取所有链接,除非该链接属于特定类或 ID

javascript - 提交处理程序仅在第二次尝试时起作用

ios - InAppBrowser OAUTH didFailLoadWithError 1004 "Could not connect to the server." "<allow-navigation> not set for url"

java - 访问用户 Google 日历 Activity

javascript - 文档.readystate = 未定义

Xcode 天气应用

google-api - Google Speech Recognition API 结果为空

python - 如何设置 Google API 凭据以通过 Jupyter Notebook 访问 AutoML API?

ios - 将 AccessToken 保存到 Google Drive API 的钥匙串(keychain)