如何在本地主机上测试谷歌联合登录
我正在尝试在本地计算机上测试联合登录应用程序。我将 django 与 Socialauth 应用程序一起使用。然而,当登录 localhost 时,我收到 403 Forbidden django 错误页面,通知我“CSRF 令牌丢失或不正确”。我假设这意味着我正在访问的网站未经授权。
在 google 域名管理页面 上,您可以添加 localhost
,但没有任何反应当您尝试管理该页面时。
那么,有没有办法在本地计算机上测试联合登录呢?
I'm trying to test a federated login application on my local machine. I'm using django together with the Socialauth application. When logging in on localhost, however, I get a 403 Forbidden django error page, informing me that the "CSRF token [is] missing or incorrect." I'm assuming that means the site I'm accessing from is not authorized.
On the google domain management page you can add localhost
, but nothing happens when you then try to manage that page.
So, is there a way to test federated login on your local machine?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
错误
意味着 django 期望的 CSRF 令牌丢失或不正确。据我所知,CSRF 令牌功能是不久前添加的,也许您需要更新 Django 安装。
The error
means just that, the CSRF token which django is expecting is missing or incorrect. AFAIK the CSRF token functionality was added not so long ago, maybe you need to update your Django install.
我的错误似乎只是没有添加 CsrfResponseMiddleware。
所以我的
settings.py
中的中间件类现在看起来像:这消除了错误,一切正常。
My mistake seems simply to have been not to have added the CsrfResponseMiddleware.
So my middleware classes in
settings.py
now looks like:This takes away the error, and everything works fine.