Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/318.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python can';t在django站点上配置facebook登录_Python_Django_Facebook_Heroku - Fatal编程技术网

Python can';t在django站点上配置facebook登录

Python can';t在django站点上配置facebook登录,python,django,facebook,heroku,Python,Django,Facebook,Heroku,我有一个由Heroku托管的个人Django网站,我正在尝试配置Facebook登录。我用的是看起来很简单的。无论我是在本地还是在生产中查看我的站点,我都会不断发现错误: 应用程序配置不允许给定URL。应用程序设置不允许一个或多个给定URL。它必须与网站URL或画布URL匹配,或者域必须是应用程序域之一的子域。 我认为这是本地的错误,没关系。我已经阅读了关于这个主题的所有其他答案,所有答案似乎都表明问题出在“基本”选项卡上的站点URL设置上。我试过: sitename.com www.site

我有一个由Heroku托管的个人Django网站,我正在尝试配置Facebook登录。我用的是看起来很简单的。无论我是在本地还是在生产中查看我的站点,我都会不断发现错误:

应用程序配置不允许给定URL。应用程序设置不允许一个或多个给定URL。它必须与网站URL或画布URL匹配,或者域必须是应用程序域之一的子域。

我认为这是本地的错误,没关系。我已经阅读了关于这个主题的所有其他答案,所有答案似乎都表明问题出在“基本”选项卡上的站点URL设置上。我试过:

  • sitename.com
  • www.sitename.com
  • http://www.sitename.com
  • https://www.sitename.com
  • sitename.herokuapp.com
没有任何区别。我错过了什么

编辑

url.py

urlpatterns = patterns('',
    url(r'^$', 'mainsite.views.base', name='base'),
    url(r'^quiz/$', 'quiz.views.quiz', name='quiz'),
    url(r'^results/$', 'quiz.views.results', name='results'),
    url(r'^wedding_party/$', 'mainsite.views.wedding_party',
        name='wedding_party'),
    url(r'^location/$', 'mainsite.views.location', name='location'),
    url(r'^story/$', 'mainsite.views.story', name='story'),
    url(r'^high_scores/$', 'quiz.views.high_scores', name='high_scores'),
    url(r'^photos/$', 'photoalbum.views.photo_album', name='photo_album'),
    url(r'^guestbook/$', 'mainsite.views.guestbook', name='guestbook'),
    url(r'^map/$', 'mainsite.views.map', name='map'),
    url(r'^afterparty/$', 'mainsite.views.afterparty', name='afterparty'),
    url(r'^lodging/$', 'mainsite.views.lodging', name='lodging'),
    url(r'^social/', include('socialregistration.urls',
        namespace='socialregistration')),
    url(r'^admin/', include(admin.site.urls)),
)
Facebook设置(我尝试过的许多配置之一):

基本>网站>网站URL:
高级>有效的OAuth重定向URI:(不确定此设置的用途)

编辑:

(画布设置是新的,但没有帮助)

设置.py

try:
    from config import SECRET_KEY, FACEBOOK_SECRET_KEY, FACEBOOK_APP_ID
    DEBUG = True
except ImportError:
    DEBUG = False
    SECRET_KEY = os.environ['SECRET_KEY']
    FACEBOOK_APP_ID = os.environ['FACEBOOK_APP_ID']
    FACEBOOK_SECRET_KEY = os.environ['FACEBOOK_SECRET_KEY']

# Django settings for wedding project.

TEMPLATE_DEBUG = DEBUG

ADMINS = (
    ('xxxx', 'xxxxx@gmail.com'),
)

MANAGERS = ADMINS

DATABASES = {
    'default': {
        # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
        # 'ENGINE': 'django.db.backends.postgresql_psycopg2',
        # 'NAME': 'django_app_1',
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': 'wedding.db',
        # The rest is not used with sqlite3:
        # 'USER': 'xxxx',
        # 'PASSWORD': 'xxxx',
        # 'HOST': 'localhost',
        # 'PORT': '5432',

    }
}
# Hosts/domain names that are valid for this site; required if DEBUG is False
# See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts
ALLOWED_HOSTS = ['*']

    # Parse database configuration from $DATABASE_URL
if not DEBUG:
    import dj_database_url
    DATABASES['default'] = dj_database_url.config()

SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')

# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# In a Windows environment this must be set to your system time zone.
TIME_ZONE = 'America/New_York'

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'

SITE_ID = 1

# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True

# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale.
USE_L10N = True

# If you set this to False, Django will not use timezone-aware datetimes.
USE_TZ = True

# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/var/www/example.com/media/"
MEDIA_ROOT = \
    '/Users/xxxxx/code/wedding/mainsite/static/images/photoalbum/'

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://example.com/media/", "http://media.example.com/"
MEDIA_URL = 'http://127.0.0.1:8000/photos/'

import os
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
STATIC_ROOT = 'mainsite/static/'
STATIC_URL = '/static/'

STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'staticfiles'),
)

# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)

# Make this unique, and don't share it with anybody.

# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
)

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    # Uncomment the next line for simple clickjacking protection:
    # 'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'django_user_agents.middleware.UserAgentMiddleware',
)

ROOT_URLCONF = 'wedding.urls'

# Python dotted path to the WSGI application used by Django's runserver.
WSGI_APPLICATION = 'wedding.wsgi.application'

TEMPLATE_DIRS = (
    'mainsite/templates',
    'quiz/templates',
    'photoalbum/templates',
)

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    # Uncomment the next line to enable the admin:
    'django.contrib.admin',
    # Uncomment the next line to enable admin documentation:
    'django.contrib.admindocs',
    'mainsite',
    'quiz',
    'photoalbum',
    'django_google_maps',
    'django_user_agents',
    'south',
    'socialregistration',
    'socialregistration.contrib.facebook'
)

# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error when DEBUG=False.
# See http://docs.djangoproject.com/en/dev/topics/logging for
# more details on how to customize your logging configuration.
LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'filters': {
        'require_debug_false': {
            '()': 'django.utils.log.RequireDebugFalse'
        }
    },
    'handlers': {
        'mail_admins': {
            'level': 'ERROR',
            'filters': ['require_debug_false'],
            'class': 'django.utils.log.AdminEmailHandler'
        }
    },
    'loggers': {
        'django.request': {
            'handlers': ['mail_admins'],
            'level': 'ERROR',
            'propagate': True,
        },
    }
}

TEMPLATE_CONTEXT_PROCESSORS = (
    'django.contrib.auth.context_processors.auth',
    'django.core.context_processors.debug',
    'django.core.context_processors.i18n',
    'django.core.context_processors.media',
    'django.core.context_processors.static',
    'django.core.context_processors.tz',
    'django.core.context_processors.request',
    'django.contrib.messages.context_processors.messages',
)

AUTHENTICATION_BACKENDS = (
    'django.contrib.auth.backends.ModelBackend',
    'socialregistration.contrib.facebook.auth.FacebookAuth',
)
编辑(站点模块) 如评论中所述,Facebook按钮导致重定向_uri=http%3A%2F%2Fexample.com%2Fsocial%2Ffacebook%2Fcallback%2F&client_i‌​d=582393191868558


example.com
来自站点模块;我删除了它,并用正确的站点域替换了它。链接现在转到:redirect_uri=http%3A%2F%2fwienerwidding.com%2Fsocial%2Ffacebook%2Fcallback%2F&client_i‌​ d=582393191868558,但仍不起作用。(同样的错误)

如果我们看不到你的fb应用程序中有什么设置,就很难说什么

试试这个:

Settings -> Basic -> Website platform -> Site URL: http://www.sitename.com/
Settings -> Advanced -> Security -> Valid OAuth redirect URIs: http://www.sitename.com/facebook/callback

请向我们展示您的facebook应用程序配置,我想这是您未填写的
应用程序域

您需要创建一个facebook应用程序,使用+添加平台

尝试以下设置:

基本>

-应用程序域:sitename.com

-Facebook上的应用程序:

--画布URL:

--安全画布URL:

高级>

-有效的OAuth重定向URI:


听起来你的URL.py有问题。你能把这些代码添加到你的问题中吗?@mevius Done and doneAdded Facebook settings didn't help——有人知道
www
是否重要吗?(我试过两种方法,只是好奇。你是否按此处所示正确填写了参数?请告诉我你的设置当我访问你的网站并单击连接时,这是我在你的url中找到的:redirect_uri=http%3A%2F%2Fexample.com%2Fsocial%2Ffacebook%2Fcallback%2F&client_id=582393191868558我认为这是错误,example.com来自?这更好,但请用您更改的内容更新您的问题以获得此结果您是否在facebook应用程序设置中填写应用程序域?在屏幕截图中,您的应用程序域为空,您应该这样填写:Basic>app domains:sitename.com