【问题标题】:gapi.auth2 returns 400 error when a domain is set for the cookie_policy当为 cookie_policy 设置域时,gapi.auth2 返回 400 错误
【发布时间】:2015-10-01 20:47:10
【问题描述】:

为我的 Angular 应用实现 https://developers.google.com/identity/sign-in/web/reference 并且登录/注销工作正常。


但是,当我为cookie_policy 参数设置域时(尝试localhost.com 域),在选择我的帐户后,它会在控制台中返回400 错误。错误的 URL 如下:

https://accounts.google.com/o/oauth2/iframerpc?action=issueToken&response_type=token%20id_token&scope=openid%20profile%20email&client_id=...apps.googleusercontent.com&login_hint=AJDL...r5Pg&ss_domain=http%3A%2F%2Flocalhost&origin=http%3A%2F%2Flocalhost%3A8000

具体报错信息为:

{
  "error" : "invalid_request",
  "error_description" : "invalid login_hint."
}

这阻碍了我通过跨子域共享的 gapi.auth2 实现身份验证。

谢谢!

【问题讨论】:

  • 嗯,它说你有一个无效的登录提示,所以可能先解决这个问题,然后根据this answer 你应该能够使用单主机源或无用于开发或您的顶级域的 url,它也应该适用于子域

标签: google-oauth google-signin


【解决方案1】:

cookie_policy 的值为single_host_origin(默认值)或none。我认为您不能将其设置为其他任何值。

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

【讨论】:

  • 但是根据docsThe domains for which to create sign-in cookies. Either a URI, single_host_origin, or none. Defaults to single_host_origin if unspecified.
猜你喜欢
  • 2015-03-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-10-31
  • 2017-09-02
  • 2017-09-30
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多