Linked API Error in Python - "Empty oauth2 access token" even though access token given

Viewed 297

I've been struggling with the following basic call to the linkedIn API.

I have received the 'OAuth 2.0 access token' through linkedIn's 'OAuth Token Tools' page and given it the proper scope (r_basicprofile) in order to complete the call. But when the call is made I get error {"serviceErrorCode":65604,"message":"Empty oauth2 access token","status":401} even though I have passed the token properly (see code below).

Any help would be greatly appreciated

import requests
import json

access_token = 'Not displayed for obvious reasons'

headers = {'Authorization': f'Bearer {access_token}'}

me = requests.get('https://api.linkedin.com/v2/me',headers=headers).json()
1 Answers

The access token param you need to pass is oauth2_access_token not access_token.

For example:

https://api.linkedin.com/v2/me?oauth2_access_token={linkedin_key}

Related