How to access Twitter API after login using Django social auth?

I would like to play with the twitter API, but I got lost with how to access the API, get TimeLine, RT, etc. after logging in with django social auth.

Can someone please provide an example of another twitter library that I can use to access streaming, timeline, etc. after authentication with Django social Auth?

I check tweepy , but I don’t see how to use it if I do not need to use the tweepy auth method.

+3
source share
3 answers

This example from the Django-social-auth documentation shows what you need:

>>> from pprint import pprint
>>> from social_auth.models import UserSocialAuth
>>> instance = UserSocialAuth.objects.filter(provider='twitter').get(...)
>>> pprint(instance.tokens)
{u'oauth_token': u'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
 u'_token_secret': u'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy'}

UserSocialAuth . tokens.

, .

+4

UserSocialAuth, :

try:
        instance = UserSocialAuth.objects.filter(user=request.user).get()
except ObjectDoesNotExist:
        return redirect(getattr(settings,'LOGIN_URL','/login/twitter/'))

:

oauth_access_token=(instance.tokens).get('oauth_token')
oauth_access_secret=(instance.tokens).get('oauth_token_secret')

, .

+2

When a user gives your application access to Twitter, you will receive a token access key and token access. Save it to your dB. You use this to access the API.

Example: https://github.com/tweepy/tweepy/blob/master/examples/oauth.py

+1
source

All Articles