【问题标题】:GoogleAuth.disconnect() on localhost doesn't work proper本地主机上的 GoogleAuth.disconnect() 无法正常工作
【发布时间】:2019-11-10 16:39:28
【问题描述】:

我的工作环境

  • localhost 与 apache2.4
  • 火狐浏览器
  • Windows 10

这是我的控制台日志:
firefox console 为什么我在disconnect() 之后仍然登录? 只有在location.reload() 我退出后...为什么?

编辑: 此外:

  1. 在 Firefox 中打开新标签页,使用 oauth2 注册 myapp
  2. 然后我打开了新的浏览器标签myaccount.google.com/permissions 和 从 myapp 中删除了权限
  3. 已检查hasGrantedScopes(SCOPE) myapp 正在运行的选项卡,并且仍然以 true 作为返回值
  4. location.reload() 在 myapp 运行的选项卡中
  5. 检查了运行 myapp 的 hasGrantedScopes(SCOPE) 选项卡并得到 false 作为返回值

【问题讨论】:

  • 尝试获取.disconnect()函数的返回值,看看效果如何
  • 我认为这对我没有帮助。该文档没有提到返回值。 developers.google.com/identity/sign-in/web/…我编辑了我的原始帖子并附加了一个控制台日志,其中包含 disconnect() 的返回值
  • 大多数方法返回一个 Promise。您能否尝试在 console.log 之前添加一些延迟
  • @Thanh 我已经在这个 console.log 中做了。即使我在 disconnect() ... 后等待几分钟...仍然登录(hasGrantedScopes(SCOPE) 返回 true)。只有在 disconnect() 完成页面刷新后,hasGrantedScopes(SCOPE) 才会返回 false
  • @Thanh GoogleAuth.disconnect().then(function (){console.log(gapi.auth2.getAuthInstance().currentUser.get().hasGrantedScopes(SCOPE));}) 返回值为 true 。还可以从我的主题问题中查看我的编辑

标签: javascript firefox youtube-api localhost disconnect


【解决方案1】:

事实证明 Googles API 并不能真正与“localhost”一起使用。

我使用来自ngrok 的服务,它会生成一个指向我的本地主机地址的公共 URL。 我在google console 中启用了从 ngrok 生成的 URL,现在一切正常。

谷歌没有在文档中提及这一点感到羞耻!

【讨论】:

    猜你喜欢
    • 2012-01-29
    • 2015-10-25
    • 2019-05-07
    • 1970-01-01
    • 2020-05-24
    • 2013-03-21
    • 2012-04-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多