Coding-With-Raptor/Likendin-Agent
0
1import requests2from agents import function_tool3from dotenv import find_dotenv, load_dotenv4import os5 6 7# Constants8LINKEDIN_ACCESS_TOKEN = os.getenv("LINKEDIN_ACCESS_TOKEN")9 10load_dotenv(find_dotenv())11 12HEADERS = {13 "Authorization": f"Bearer {LINKEDIN_ACCESS_TOKEN}",14 "Content-Type": "application/json",15}16 17 18@function_tool19def get_user_info():20 """21 Retrieve LinkedIn user profile information using the /userinfo endpoint.22 23 Returns:24 dict: User profile information or None if an error occurs.25 """26 url = "https://api.linkedin.com/v2/userinfo"27 28 try:29 response = requests.get(url, headers=HEADERS)30 response.raise_for_status()31 return response.json()32 except requests.exceptions.RequestException as e:33 print(f"Error fetching user info: {e}")34 return None35 