· 7 years ago · Aug 06, 2018, 01:28 PM
1twitter does not work in django socialauth
2TWITTER_CONSUMER_KEY = 'Mk' this is no real
3TWITTER_CONSUMER_SECRET = 'MTw' this is no real
4FACEBOOK_APP_ID = ''
5FACEBOOK_API_SECRET = ''
6LINKEDIN_CONSUMER_KEY = ''
7LINKEDIN_CONSUMER_SECRET = ''
8ORKUT_CONSUMER_KEY = ''
9ORKUT_CONSUMER_SECRET = ''
10GOOGLE_OAUTH2_CLIENT_ID = ''
11GOOGLE_OAUTH2_CLIENT_SECRET = ''
12SOCIAL_AUTH_CREATE_USERS = True
13SOCIAL_AUTH_FORCE_RANDOM_USERNAME = False
14SOCIAL_AUTH_DEFAULT_USERNAME = 'socialauth_user'
15SOCIAL_AUTH_COMPLETE_URL_NAME = 'socialauth_complete'
16LOGIN_ERROR_URL = '/login/error/'
17#SOCIAL_AUTH_USER_MODEL = 'app.CustomUser'
18SOCIAL_AUTH_ERROR_KEY = 'socialauth_error'
19GITHUB_APP_ID = ''
20GITHUB_API_SECRET = ''
21FOURSQUARE_CONSUMER_KEY = ''
22FOURSQUARE_CONSUMER_SECRET = ''
23
24from os.path import abspath, dirname, basename, join
25
26try:
27 import social_auth
28except ImportError:
29 import sys
30 sys.path.insert(0, "..")
31
32DEBUG = True
33TEMPLATE_DEBUG = DEBUG
34
35ROOT_PATH = abspath(dirname(__file__))
36PROJECT_NAME = basename(ROOT_PATH)
37
38ADMINS = (
39 # ('Your Name', 'your_email@domain.com'),
40)
41MANAGERS = ADMINS
42
43DATABASES = {
44 'default': {
45 'ENGINE': 'django.db.backends.sqlite3',
46 'NAME': 'test.db',
47 }
48}
49
50TIME_ZONE = 'America/Chicago'
51LANGUAGE_CODE = 'en-us'
52SITE_ID = 1
53
54USE_I18N = True
55USE_L10N = True
56
57MEDIA_ROOT = ''
58ADMIN_MEDIA_PREFIX = '/admin-media/'
59MEDIA_URL = ''
60
61SECRET_KEY = 't2eo^kd%k+-##ml3@_x__$j0(ps4p0q6eg*c4ttp9d2n(t!iol'
62
63TEMPLATE_LOADERS = (
64 'django.template.loaders.filesystem.Loader',
65 'django.template.loaders.app_directories.Loader',
66)
67
68MIDDLEWARE_CLASSES = (
69 'django.middleware.common.CommonMiddleware',
70 'django.contrib.sessions.middleware.SessionMiddleware',
71 'django.middleware.csrf.CsrfViewMiddleware',
72 'django.contrib.auth.middleware.AuthenticationMiddleware',
73 'django.contrib.messages.middleware.MessageMiddleware',
74)
75
76ROOT_URLCONF = 'example.urls'
77
78TEMPLATE_DIRS = (
79 join(ROOT_PATH, 'templates')
80)
81
82INSTALLED_APPS = (
83 'django.contrib.auth',
84 'django.contrib.contenttypes',
85 'django.contrib.sessions',
86 'django.contrib.sites',
87 'django.contrib.messages',
88 'django.contrib.admin',
89 'social_auth',
90 'app',
91)
92SOCIAL_AUTH_ENABLED_BACKENDS = ('google', 'google-oauth', 'facebook', 'twitter')
93
94AUTHENTICATION_BACKENDS = (
95 'social_auth.backends.twitter.TwitterBackend',
96 'social_auth.backends.facebook.FacebookBackend',
97 'social_auth.backends.google.GoogleOAuthBackend',
98 'social_auth.backends.google.GoogleOAuth2Backend',
99 'social_auth.backends.google.GoogleBackend',
100 'social_auth.backends.yahoo.YahooBackend',
101 'social_auth.backends.contrib.linkedin.LinkedinBackend',
102 'social_auth.backends.contrib.flickr.FlickrBackend',
103 'social_auth.backends.OpenIDBackend',
104 'social_auth.backends.contrib.livejournal.LiveJournalBackend',
105 'django.contrib.auth.backends.ModelBackend',
106)
107
108
109TEMPLATE_CONTEXT_PROCESSORS = (
110 'django.contrib.auth.context_processors.auth',
111 'django.core.context_processors.debug',
112 'django.core.context_processors.i18n',
113 'django.core.context_processors.media',
114 'django.contrib.messages.context_processors.messages',
115 'social_auth.context_processors.social_auth_by_type_backends',
116)
117
118LOGIN_REDIRECT_URL = '/'
119
120try:
121 from local_settings import *
122except:
123 pass
124
125AUTHENTICATION_BACKENDS = (
126 'social_auth.backends.google.TwitterBackend',
127)
128
129SOCIAL_AUTH_ENABLED_BACKENDS = ('twitter',)
130
131TWITTER_CONSUMER_KEY = 'xxx'
132TWITTER_CONSUMER_SECRET = 'yyy'
133
134INSTALLED_APPS = (
135 'django.contrib.auth',
136 'django.contrib.contenttypes',
137 'django.contrib.sessions',
138 'django.contrib.sites',
139 'django.contrib.messages',
140 'django.contrib.staticfiles',
141 'social_auth',
142)
143
144url(r'', include('social_auth.urls')),
145
146% python manage.py syncdb