Set Up LinkedIn Marketing API: Quick Guide to OAuth and Developer Account Configuration
Hello and welcome! Thank you for visiting my comprehensive LinkedIn Marketing API Integration setup guide. In this guide, you’ll learn how to effectively set up a LinkedIn developer account, create and configure a LinkedIn API App, and enable the LinkedIn Advertising API permission to complete LinkedIn Marketing API integration. Not to forget at the end there will be code to make your first API calls using the Python3 programming language. Whether you’re a seasoned developer or just getting started, this step-by-step guide is designed to simplify the LinkedIn Marketing API Integration (configuration) process, making it easy to implement and accessible to all skill levels. Let’s get started with LinkedIn Marketing API Integration!
What is the LinkedIn API?
The LinkedIn API (also known as the LinkedIn Marketing API) is a powerful tool that enables you to programmatically interact with LinkedIn’s vast professional network. With the LinkedIn API, you can:
- Query data: Access and analyze valuable insights about LinkedIn users, companies, and trends.
- Manage ads and campaigns: Create, optimize, and track the performance of your LinkedIn advertising campaigns.
- Get account-related data: Retrieve information about your LinkedIn account, including settings, usage, and billing.
- Perform various other tasks: Automate various LinkedIn activities and integrate LinkedIn data into your applications.
The LinkedIn API is a RESTful API that enables programmatic interactions with LinkedIn’s platform. This guide will walk you through the steps required to use the LinkedIn API successfully.
Table of Contents:
- Create an App on LinkedIn Developer
- Enabling Advertising API
- Get Access Token
- Making the First API call
Quick Access:
If you’re looking to maximize the potential of LinkedIn API integration, I’m here to help. Whether you have questions, need guidance, or automated token generation solutions, or require tailored consulting services, don’t hesitate to reach out. Let’s discuss how I can assist you in achieving your goals in just no time. Connect with me through the provided Contact Form, and let’s start a conversation about your unique requirements.
1. Create an App in the LinkedIn Developer Portal
Start by navigating to the LinkedIn Developer Portal. Log in using your LinkedIn account credentials if you’re not already signed in. Once logged in, you’ll be directed to the dashboard, where you can begin setting up your application, as shown in the screenshot below.
To create a new app, fill in the required details in the form and click the “Create App” button.
NOTE: you will need to give your LinkedIn company page link or name to create this app.
Once submitted, your app will be successfully created. In the example below, you can see the screenshot of my newly created app.
The final step is to verify your company account.
Above while creating the app you have asked to give the LinkedIn company page link or name. If you have not given then, no problem, you will have to give that detail now. Once you’ve entered this information, click the “Verify” button. A pop-up titled “Verify Company” will appear. Click the “Generate URL” button within the pop-up to proceed with the verification process.
If you’re the creator of the LinkedIn company page or have admin access, copy the verification link and open it in a new tab. Click “Verify“.
If you’re not an admin, send the link to the page admin and ask them to verify it.
Once verified, return to the “Verify Company” pop-up and click “I’m done“.
You should now be back on the LinkedIn Developers Portal. Refresh your page. If you are not back on your newly created app, then select the app you just created from the “My Apps” menu.
2. Enable Advertising API permissions
To be able to generate access tokens and extract data from LinkedIn campaign managers using the LinkedIn API developer APP you will need to have access to Advertising API permission.
To generate access tokens and extract reporting/analytics data of campaigns from LinkedIn Campaign Managers, you’ll need to enable Advertising API permissions for your LinkedIn API app.
Requesting Advertising API Permissions
If you’ve followed the previous steps, you should be on a screen similar to the screenshot below. Click on the “Products” tab, find the “Advertising API” product, and click “Request Access“.
A pop-up will appear requesting your consent to LinkedIn’s Product Terms and Conditions. Read the terms carefully and agree to them. Then, click “Request Access” again.
Next, you’ll see an option to access the “request form”. A link to the access request form will appear within a few minutes. Complete the form to finalize your application for Advertising API access.
Note: After submitting the form, please allow up to 24 hours for your application to be processed.
3. Generate Access Token and Refresh Token
To streamline the process of generating access tokens and refresh tokens, I’ve developed a Python script specifically for this purpose. If you’d like to get access to the code, feel free to get in touch with me directly on WhatsApp at +91 7892353323. You can also connect with me through LinkedIn or the provided Contact Form.
I’ll be happy to share the script and guide you through the process to ensure smooth integration with the LinkedIn API.
4. Test the Access Token
Once you have your access token, it’s important to verify its functionality. Here’s how:
- Securely Store Credentials: Store your access token, refresh token, expiry time, and other credentials in a secure manner.
- Ideally some cloud secure storage like “AWS Secret”.
- Use the .env file (i.e. environment file) to store the credentials. A text file that stores environment variables for a project. I would recommend this way of storing the API App cred for this guide.
- You can use JSON files. I won’t recommend it, as it’s less secure and more susceptible to unauthorized access.
- Test Code Example: This guide provides a Python code example named “access_token_check.py“. You can find the code further down in this guide or from my GitHub repo through GitHub Link.
- Run the Test Script: Save the Python code and run it using the command python3 ./access_token_check.py (replace the path if needed).
Verify Output: If the script runs successfully, you should see your LinkedIn profile data printed in the terminal. This confirms that your access token is working and ready for use with your LinkedIn Advertising API applications.
Example of a .env file:
CLIENT_ID = "<Replace with your API app client ID >" CLIENT_SECRET = "<Replace with your API app client secret >" ACCESS_TOKEN = "<Replace with your API app access token >"
Python3 Code for Testing the working of Access Token
#!/usr/bin/python3 import requests import json import os from dotenv import load_dotenv load_dotenv() def test_token(access_token): url = "https://api.linkedin.com/v2/me" headers = {"Authorization": "Bearer "+access_token} #make the http call r = requests.get(url = url, headers = headers) if r.status_code != 200: print("something went wrong :",r) else: response_dict = json.loads(r.text) print("Account Description :\n",response_dict) if __name__ == '__main__': client_id = os.getenv("CLIENT_ID") client_secret = os.getenv("CLIENT_SECRET") access_token = os.getenv("ACCESS_TOKEN") print(f"\n Client ID is {client_id}") test_token(access_token)
If you see the above output that means the access_token you generated through the above process is working and you are good to go with your advanced application using LinkedIn Marketing/Advertising API.
Congratulation! you have successfully set up LinkedIn API. Now, here’s my guide to help you develop complete Python code with a step-by-step guide for extracting LinkedIn campaign reporting and analytics data using LinkedIn API. End-To-End LinkedIn Campaign Data Extraction Programmatic Solution.
Hope I was able to solve the problem. If you like this article and think it was easy to understand do share it with your friends and connection. Thank you! See you soon.
Checkout out my other API Integration and Coding Solution Guide
For any suggestions or doubts ~ Get In Touch