ozgur / python-linkedin

Python interface to the LinkedIn API
http://ozgur.github.com/python-linkedin/
MIT License
889 stars 394 forks source link

Issue with getting the access token #52

Open technofriends opened 10 years ago

technofriends commented 10 years ago

Linkedin's developer documentation states that the URl should have the following structure when making a request for the access https://www.linkedin.com/uas/oauth2/accessToken?grant_type=authorization_code &code=AUTHORIZATION_CODE &redirect_uri=YOUR_REDIRECT_URI &client_id=YOUR_API_KEY &client_secret=YOUR_SECRET_KEY

Therefore, should the get_access_token() not be rewritten as:

def get_access_token(self, timeout=60):
    assert self.authorization_code, 'You must first get the authorization code'
    qd = {'grant_type': 'authorization_code',
          'code': self.authorization_code,
          'redirect_uri': self.redirect_uri,
          'client_id': self.key,
          'client_secret': self.secret}
    qsl = ['%s=%s' % (urllib.quote(k), urllib.quote(v)) for k, v in qd.items()]
    fullURL = '%s?%s' % (self.ACCESS_TOKEN_URL, '&'.join(qsl))

    response = requests.post(fullURL, timeout=timeout)
    raise_for_error(response)
    response = response.json()
    self.token = AccessToken(response['access_token'], response['expires_in'])
    return self.token
plandevida commented 10 years ago

Hi,

What is the correct code that you suggest?

Regards.

kvaghas commented 8 years ago

Any luck with this? Facing similar issue.

wuwenhuang commented 6 years ago

yes based on linkedin redirect url. use the code that passed in the url from request and set authentication_code

wuwenhuang commented 6 years ago

based on Django linkedin_authorization_code = request.GET['code'] linkedin.LinkedInAuthentication("auth_key", "auth_secret", "redirect_url") linkedin_auth.authorization_code = linkedin_authorization_code