I'm trying to get a website to connect to LinkedIn, I know I have to use OAuth tokens to connect to it, and I have seen the examples on the LinkedIn developer site, however, they all use the OAuth2 library and the site that I'm working with uses the rauth library, which seems to skip a few of the steps. It already has Twitter integrated, so I'll include the code below in case anyone doesn't quite understand what I mean.
twitter.py:
import json
from django.http import HttpResponse
from django.conf import settings
from rauth.service import OAuth1Service
def twitter(request, username):
twitter = OAuth1Service(
name='twitter',
consumer_key=settings.TWITTER_CONSUMER_KEY,
consumer_secret=settings.TWITTER_CONSUMER_SECRET,
request_token_url=settings.TWITTER_API_URL + 'oauth/request_token',
access_token_url=settings.TWITTER_API_URL + 'oauth/access_token',
authorize_url=settings.TWITTER_API_URL + 'oauth/authorize',
header_auth=True)
url = '{0}1/statuses/user_timeline.json?include_rts=false' \
'&exclude_replies=true&count=50&screen_name={1}'.format(
settings.TWITTER_API_URL, username)
r = twitter.request('GET', url, access_token=settings.TWITTER_USER_KEY,
access_token_secret=settings.TWITTER_USER_SECRET)
return HttpResponse(content=json.dumps(r.response.json),
status=r.response.status_code,
content_type=r.response.headers['content-type'])
Since it isn't commented, I think it's makes a request to the url
which returns the user's timeline when sent, but how come there's no request token creation OR access token creation? It has the TWITTER_USER_KEY
and TWITTER_USER_SECRET
, but the rauth documentation says you should call explicit methods to get the tokens. What am I missing here?
EDIT: I'd quite like to just use the rauth library, and not meddle around with other libraries too.