In [4]:
import random, json
from rauth import OAuth2Service

linkedin = OAuth2Service(
    client_id='77yy744nq5ogpd',
    client_secret='mHIGRRFUtMs5sRO3',
    name='linkedin',
    authorize_url='https://www.linkedin.com/uas/oauth2/authorization',
    access_token_url='https://www.linkedin.com/uas/oauth2/accessToken',
    base_url='https://api.linkedin.com/v1/')

redirect_uri = 'http://localhost:8000/auth/linkedin/callback'

params = {'scope': 'r_basicprofile',
          'state': '12345678',
          'response_type': 'code',
          'redirect_uri': redirect_uri}

authorize_url = linkedin.get_authorize_url(**params)

print 'Acessar url: ' + authorize_url
code = raw_input('Digitar o código do navegador: ')

session = linkedin.get_auth_session(data={'code': code,
                                           'redirect_uri':e redirect_uri})


Acessar url: https://www.linkedin.com/uas/oauth2/authorization?scope=r_basicprofile&state=12345678&redirect_uri=http%3A%2F%2Flocalhost%3A8000%2Fauth%2Flinkedin%2Fcallback&response_type=code&client_id=77yy744nq5ogpd
Digitar o código do navegador: AQSWaHHukxODJpc8GXElkPz1AHhfi-N-wC6lgCmU7oTSK_ylUZNe-_3LYUk6oHZ0_ijGQFNLxd0sO-4RUgurf9nkcyrtY6jBE0KVdtrayWl1-pUEzz8&state=12345678
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-4-372a33dbced0> in <module>()
     23 
     24 session = linkedin.get_auth_session(data={'code': code,
---> 25                                            'redirect_uri': redirect_uri})

/Users/thiago/Envs/tcc-py2/lib/python2.7/site-packages/rauth/service.pyc in get_auth_session(self, method, **kwargs)
    554         :type \*\*kwargs: dict
    555         '''
--> 556         session = self.get_session(self.get_access_token(method, **kwargs))
    557 
    558         if self.access_token_response:

/Users/thiago/Envs/tcc-py2/lib/python2.7/site-packages/rauth/service.pyc in get_access_token(self, method, decoder, key, **kwargs)
    540         '''
    541         r = self.get_raw_access_token(method, **kwargs)
--> 542         access_token, = process_token_request(r, decoder, key)
    543         return access_token
    544 

/Users/thiago/Envs/tcc-py2/lib/python2.7/site-packages/rauth/service.pyc in process_token_request(r, decoder, *args)
     22     except KeyError as e:  # pragma: no cover
     23         bad_key = e.args[0]
---> 24         raise KeyError(PROCESS_TOKEN_ERROR.format(key=bad_key, raw=r.content))
     25 
     26 

KeyError: 'Decoder failed to handle access_token with data as returned by provider. A different decoder may be needed. Provider returned: {"error_description":"missing required parameters, includes an invalid parameter value, parameter more than once. : grant_type","error":"invalid_request"}'

In [ ]:
r = session.get('people/~/',
                params={'type': 'SHAR', 'format': 'json'},
                header_auth=True)

updates = r.json()

print updates