TWITTER_CONSUMER_KEY
TWITTER_CONSUMER_SECRET
-Twitter demands a redirect url configuration and will force the user
-to that address when redirecting, and http://127.0.0.1:8000 won't
-work. As a development hack, I suggest to setup something like
-http://myvirtualapp.com and adding an entry in /etc/hosts for that
-address pointing to localhost, port will be missed, but will do the
-trick for testing.
-
-If you cannot resit the missing port issue, play a bit with dnsmasq_.
-
+ - You don't need to specify the url callback
--------
Facebook
from django.conf import settings
from django.utils import simplejson
from django.contrib.auth import authenticate
+from django.core.urlresolvers import reverse
from .base import BaseAuth
from .store import DjangoOpenIDStore
class TwitterAuth(BaseAuth):
"""Twitter OAuth authentication mechanism"""
+ def __init__(self, request, redirect):
+ super(TwitterAuth, self).__init__(request, redirect)
+ self.redirect_uri = self.request.build_absolute_uri(reverse('social:complete', args=['twitter']))
+
def auth_url(self):
"""Returns redirect url"""
token = self.unauthorized_token()
return None
def oauth_request(self, token, url):
- request = OAuthRequest.from_consumer_and_token(self.consumer, token=token, http_url=url)
+ params = {'oauth_callback': self.redirect_uri}
+ request = OAuthRequest.from_consumer_and_token(self.consumer, token=token, http_url=url, parameters=params)
request.sign_request(OAuthSignatureMethod_HMAC_SHA1(), self.consumer, token)
return request