oauth2.0 为http://192.168.64.2:8000授权重定向URI添加www.example.com域

yzuktlbb  于 2023-03-11  发布在  其他
关注(0)|答案(2)|浏览(217)

我正在尝试添加谷歌授权重定向URI我已经添加了两个域用于本地测试http://127.0.0.1:8000/app/oauth/complete/google-oauth2/http://localhost:8000/app/oauth/complete/google-oauth2/
以上两个域工作正常
但是当我想把http://192.168.64.2:8000/app/oauth/complete/google-oauth2
显示以下错误

Invalid Redirect: must end with a public top-level domain (such as .com or .org).
Invalid Redirect: domain must be added to the authorized domains list before submitting.

http://192.168.64.2:8000/app/oauth/complete/google-oauth2添加为授权重定向URI的域实际上有什么问题?

70gysomp

70gysomp1#

您不能添加不是127.0.0.1的IP地址。如果您想添加这样的位置,您需要设置一个服务器,并使其可以从公共www域访问。

n3h0vuf2

n3h0vuf22#

是的,您不能将IP地址添加到授权的URL
AWS ec2示例有两个PublicIPAddressPublicDnsName
PublicDnsName看起来像ec2-113-34-20-346.app-north-4.compute.amazonaws.com,您必须检查您的示例以获得更多细节。
PublicDnsName添加到ALLOWED_HOSTSCSRF_TRUSTED_ORIGINS
settings.py

ALLOWED_HOSTS = ['ec2-113-34-20-346.app-north-4.compute.amazonaws.com', 'ec2-113-34-20-346.app-north-4.compute.amazonaws.com:8000']

CSRF_TRUSTED_ORIGINS = ['http://ec2-113-34-20-346.app-north-4.compute.amazonaws.com', 'http://ec2-113-34-20-346.app-north-4.compute.amazonaws.com:8000']

在谷歌控制台中将其添加到授权的url

http://ec2-113-34-20-346.app-north-4.compute.amazonaws.com:8000/accounts/google/login/callback/

相关问题