1

I'm trying to log-in to Linkedin. I created the App and extract the client_key and client_secret. Also I added http://localhost:8080/ as Redirect URLs. I have this error:

linkedin.exceptions.LinkedInError: 410 Client Error: Gone for url: https://api.linkedin.com/v1/people/~: This resource is no longer available under v1 APIs

# pip install python-linkedin
from linkedin import linkedin
import oauth2 as oauth
import urllib

consumer_key = ''
consumer_secret = ''

consumer = oauth.Consumer(consumer_key, consumer_secret)
client = oauth.Client(consumer)

request_token_url = 'https://api.linkedin.com/uas/oauth/requestToken'
resp, content = client.request(request_token_url, "POST")
if resp['status'] != '200':
    raise Exception('Invalid response %s.' % resp['status'])
content_utf8 = str(content, 'utf-8')
request_token = dict(urllib.parse.parse_qsl(content_utf8))
authorize_url = request_token['xoauth_request_auth_url']

print('Go to the following link in your browser:', "\n")
print(authorize_url + '?oauth_token=' + request_token['oauth_token'])

accepted = 'n'
while accepted.lower() == 'n':
    accepted = input('Have you authorized me? (y/n)')
oauth_verifier = input('What is the PIN?')

access_token_url = 'https://api.linkedin.com/uas/oauth/accessToken'
token = oauth.Token(request_token['oauth_token'], request_token['oauth_token_secret'])
token.set_verifier(oauth_verifier)
client = oauth.Client(consumer, token)
resp, content = client.request(access_token_url, 'POST')
content8 = str(content, 'utf-8')
access_token = dict(urllib.parse.parse_qsl(content8))
USER_TOKEN = access_token['oauth_token']
USER_SECRET = access_token['oauth_token_secret']
RETURN_URL = 'http://localhost:8080'

authentication = linkedin.LinkedInDeveloperAuthentication(
    consumer_key,
    consumer_secret,
    USER_TOKEN,
    USER_SECRET,
    RETURN_URL,
    linkedin.PERMISSIONS.enums.values()
)
application = linkedin.LinkedInApplication(authentication)
application.get_profile()
3
  • 1
    whats your question Commented Aug 1, 2019 at 19:21
  • I cant get_profile() info Commented Aug 1, 2019 at 19:24
  • right and the API response is 410 which means that this specific resource is no longer available. So basically the address is not there, don't blame yourself on your code. developer.mozilla.org/en-US/docs/Web/HTTP/Status/410 Commented Aug 1, 2019 at 19:27

1 Answer 1

1

The v1 APIs are no longer supported.
Applications requesting Version 1.0 APIs may experience issues as they are removing services. Hence, it is highly recommended to change it from v1 to v2.
Link : https://engineering.linkedin.com/blog/2018/12/developer-program-updates
Try updating your code with the new set of APIs (currently v2), and it will work perfectly as you're expecting.
Link : https://pypi.org/project/python-linkedin-v2/

Hope it helps!

Sign up to request clarification or add additional context in comments.

7 Comments

I did that but now i have this error: 401 Client Error: Unauthorized for url: api.linkedin.com/v2/me
Change request_token_url to https://www.linkedin.com/oauth/v2/accessToken, and then let me know what reponse you obtain.
Exception: Invalid response 400
You'll have to make a few changes in your code as mentioned here : pypi.org/project/python-linkedin-v2
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.