【发布时间】:2019-04-10 14:22:18
【问题描述】:
我正在使用谷歌应用引擎
我的设置文件
import pymysql # noqa: 402
pymysql.install_as_MySQLdb()
if os.getenv('GAE_APPLICATION', None):
# Running on production App Engine, so connect to Google Cloud SQL using
# the unix socket at /cloudsql/<your-cloudsql-connection string>
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'HOST': '/cloudsql/connectionstring',
'USER': 'myusername',
'PASSWORD': 'mypasswor',
'NAME': 'mydbname',
}
}
else:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'HOST': '127.0.0.1',
'PORT': '3306',
'USER': 'username',
'PASSWORD': 'mypassword',
'NAME': 'dbname',
}
}
工作正常..
现在我尝试使用 social-auth-app-django 实现 google 身份验证
从谷歌重定向后显示以下错误:
OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] 连接被拒绝)") 连接 (/env/lib/python3.7/site-packages/pymysql/connections.py:629)
【问题讨论】:
-
检查您传递给 Google 的重定向 URL。您确定它试图将您送回您的 App Engine 实例,而不是您的本地开发环境吗?
/cloudsql/connectionstring实际上并不是您要使用的连接字符串,对吧? -
@kungphu google 重定向到我的公共域而不是本地主机,我认为我不应该透露我的连接字符串,它仅在从 google 重定向时才起作用。
-
您只有一个
settings.py文件,还是有单独的dev和production设置文件? -
你找到解决这个问题的方法了吗?
标签: python django python-3.x google-app-engine pymysql