Google Openid: Is this an acceptable way to logout?

旧城冷巷雨未停 提交于 2019-12-23 20:10:29

问题


I am using google open id on my website as a login system. I ran into some trouble with logging a user out. Destroying the session on the site obviously doesn't log them out of the google account, and on the next login the user automatically logs in with whatever google account the browser is logged into.

Looking at a few questions on here, I discovered I could just make a request to https://www.google.com/accounts/Logout

I tried using

<script type="text/javascript">
    $.ajax({ url: "https://www.google.com/accounts/Logout" });
</script>

but it did not work and I'm not sure why. However this works just fine

<img src="https://www.google.com/accounts/Logout" />

Can anyone explain to me why the ajax request doesn't work?

Edit:

More importantly, what is the best way to send the request? An img tag doesn't seem like a nice solution. Thanks


回答1:


You cannot make cross-domain requests using jQuery's $.ajax, see Same origin policy so that is why your first solution does not work.

Edit: I am not familiar with how Google's OpenID works, but as a user I would not use an app that logs me out of Google when I want to logout of the app; that's a bad user experience.



来源:https://stackoverflow.com/questions/14450652/google-openid-is-this-an-acceptable-way-to-logout

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