0

I'm trying to authenticate the LinkedIn API to retrieve data from company pages using my LinkedIn App credentials.

Under Oauth 2.0 settings:

Redirect URLs: http://localhost:8000/

Wasn't entirely sure which URLS to add in above.

from requests_oauthlib import OAuth2Session
from requests_oauthlib.compliance_fixes import linkedin_compliance_fix


# Credentials you get from registering a new application
client_id = '*********'
client_secret = '********'
redirect_url = 'http://localhost:8000/'

# OAuth endpoints given in the LinkedIn API documentation (you can check for the latest updates)
authorization_base_url ='https://www.linkedin.com/oauth/v2/authorization'
token_url = 'https://www.linkedin.com/oauth/v2/accessToken'

# Authorized Redirect URL (from LinkedIn configuration)
linkedin = OAuth2Session(client_id, redirect_uri=redirect_url)
linkedin = linkedin_compliance_fix(linkedin)

# Redirect user to LinkedIn for authorization
authorization_url, state = 
linkedin.authorization_url(authorization_base_url)
print('Please go here and authorize,', authorization_url)

# Get the authorization verifier code from the callback url
redirect_response = input('Paste the full redirect URL here:')

# Fetch the access token
linkedin.fetch_token(token_url, client_secret=client_secret,
                 authorization_response=redirect_response)

# Fetch a protected resource, i.e. user profile
r = linkedin.get('https://api.linkedin.com/v1/people/~')
print(r.content)

After opening the URL and logging in & authorizing the client, I keep getting this error: InvalidClientIdError: (invalid_request) A required parameter "client_id" is missing

I'm sure these are the most up to date URLs to use for LinkedIn

1 Answer 1

1

This is a bit late, but I came across this same problem today.

The solution lies in passing a flag that forces the use of client_id:

linkedin.fetch_token(token_url, client_secret=client_secret, authorization_response=redirect_response, include_client_id=True)

I hope that helps!

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

Comments

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.